Title: Model year incorrectly identified for certain heavy vehicles · Issue #24 · h3/python-libvin · GitHub
Open Graph Title: Model year incorrectly identified for certain heavy vehicles · Issue #24 · h3/python-libvin
X Title: Model year incorrectly identified for certain heavy vehicles · Issue #24 · h3/python-libvin
Description: Issue The current implementation of Vin.year returns the incorrect year for some heavy trucks and vans: In [1]: from libvin import Vin In [2]: v = Vin('1FUJGLDR69LAC9984') In [3]: v.year Out[3]: 2039 In [4]: v.is_pre_2010 Out[4]: False T...
Open Graph Description: Issue The current implementation of Vin.year returns the incorrect year for some heavy trucks and vans: In [1]: from libvin import Vin In [2]: v = Vin('1FUJGLDR69LAC9984') In [3]: v.year Out[3]: 20...
X Description: Issue The current implementation of Vin.year returns the incorrect year for some heavy trucks and vans: In [1]: from libvin import Vin In [2]: v = Vin('1FUJGLDR69LAC9984') In [3]: v.year Ou...
Opengraph URL: https://github.com/h3/python-libvin/issues/24
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Model year incorrectly identified for certain heavy vehicles","articleBody":"# Issue\r\nThe current implementation of `Vin.year` returns the incorrect year for some heavy trucks and vans:\r\n\r\n```python\r\nIn [1]: from libvin import Vin\r\n\r\nIn [2]: v = Vin('1FUJGLDR69LAC9984')\r\n\r\nIn [3]: v.year\r\nOut[3]: 2039\r\n\r\nIn [4]: v.is_pre_2010\r\nOut[4]: False\r\n```\r\nThe correct model year for this VIN is 2009 [(source)](https://www.vindecoderz.com/EN/check-lookup/1FUJGLDR69LAC9984).\r\n\r\nFor vehicles with a gross vehicle weight rating (GVWR) over 10,000 lbs the 7th digit of the VIN does not indicate if the vehicles was manufactured before or after 2009 as it does for passenger vehicles.\r\n\r\n# Potential solutions\r\nOne potential solution(https://github.com/emesterhazy/python-libvin/commit/58de6905448b774de2127944b76198400b3f46e7) is to check `Vin.year` and overwrite the `is_pre_2010` condition if the model year is more than X years into the future. For the example above, the fix would check the model year when the `Vin` object is created, and overwrite the `is_pre_2010` property since 2039 is too far into the future. Then when `Vin.year` is accessed it will return the correct year (2009), and `Vin.is_pre_2010` will return `True`.\r\n\r\n```python\r\nclass Vin(object):\r\n def __init__(self, vin):\r\n self.vin = vin.upper()\r\n\r\n # Overwrite is_pre_2010 attribute if it would result in a model year\r\n # more than 2 years into the future. See notes in is_pre_2010\r\n self._pre_2010_overwrite = False\r\n if (not self.is_pre_2010 and\r\n YEARS_CODES_PRE_2040[self.vin[9]] \u003e= datetime.now().year + 2):\r\n self._pre_2010_overwrite = True\r\n\r\n...\r\n\r\n @property\r\n def is_pre_2010(self):\r\n\r\n if self._pre_2010_overwrite:\r\n return True\r\n else:\r\n return self.vin[6].isdigit()\r\n\r\n```\r\n\r\nThe downside to this is that the fix will also \"correct\" valid passenger car VINs for vehicles with model years more than 2 years into the future. However, I don't think this will be an issue in real world use.\r\n\r\nI have a pull request ready if you agree with this approach.","author":{"url":"https://github.com/emesterhazy","@type":"Person","name":"emesterhazy"},"datePublished":"2018-08-25T16:43:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/24/python-libvin/issues/24"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c772ef7d-5f3a-0e78-8039-e943b0d91848 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 894C:376B66:1B453:2382A:6A5EC960 |
| html-safe-nonce | db03556f604acc66e1aac6f921958b05415efd48693309e76f7f085a7f3e4fb8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTRDOjM3NkI2NjoxQjQ1MzoyMzgyQTo2QTVFQzk2MCIsInZpc2l0b3JfaWQiOiI3NjY1MzUyMTQ2NzIzMDAzODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 18ee15a6488a1ff9849deef44a795dae29a0aeef13de8a12cd2e3ab77f9c0d08 |
| hovercard-subject-tag | issue:354026429 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/h3/python-libvin/24/issue_layout |
| twitter:image | https://opengraph.githubassets.com/09f32534d90bdbead0ac6de4fc86ed7fcc4caad7ba564413d27cb735c918ecea/h3/python-libvin/issues/24 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/09f32534d90bdbead0ac6de4fc86ed7fcc4caad7ba564413d27cb735c918ecea/h3/python-libvin/issues/24 |
| og:image:alt | Issue The current implementation of Vin.year returns the incorrect year for some heavy trucks and vans: In [1]: from libvin import Vin In [2]: v = Vin('1FUJGLDR69LAC9984') In [3]: v.year Out[3]: 20... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | emesterhazy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9bd00899c80f8b6ea4e7a96c99290af4722b0befdf9e021b19232cbd6f993660 |
| turbo-cache-control | no-preview |
| go-import | github.com/h3/python-libvin git https://github.com/h3/python-libvin.git |
| octolytics-dimension-user_id | 102919 |
| octolytics-dimension-user_login | h3 |
| octolytics-dimension-repository_id | 5062758 |
| octolytics-dimension-repository_nwo | h3/python-libvin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 5062758 |
| octolytics-dimension-repository_network_root_nwo | h3/python-libvin |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9996307881fdf9017d864a20b3dfe5aae4dddd3e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width