1

So I'm using vininfo to populate information about some units from an external DB using their VIN only and to work with this data I am converting it to a dict using annotate() or annotate().items() but the script breaks down on

TypeError: cannot unpack non-iterable NoneType object

Tried using hasattr(obj, 'attr') but it explodes there with the same error. Cannot iterate with a for..in because the object is not an iterable TypeError: 'NoneType' object is not iterable.

I tried on the CLI version with the same VIN and it spits out the same cannot unpack error.

The thing is this VIN I'm using to test is missing some data .transmission to be precise (but I guess it'll happen with any other field), probably due to a misspelling when filling the registration form so I'm trying to ignore this field but I can't because it doesn't exist!

The VIN is: 1NKZXPEX4GJ109010

The Traceback is the following:

Traceback (most recent call last):
  File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python37\Scripts\vininfo.exe\__main__.py", line 7, in <module>
  File "c:\program files\python37\lib\site-packages\vininfo\cli.py", line 51, in main
    entry_point(obj={})
  File "c:\program files\python37\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files\python37\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\program files\python37\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files\python37\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files\python37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python37\lib\site-packages\vininfo\cli.py", line 35, in show
    out(details)
  File "c:\program files\python37\lib\site-packages\vininfo\cli.py", line 24, in out
    for k, v in annotatable.annotate().items():
  File "c:\program files\python37\lib\site-packages\vininfo\common.py", line 17, in annotate
    value = getattr(self, attr_name, no_attr)
  File "c:\program files\python37\lib\site-packages\vininfo\details\_base.py", line 53, in __get__
    return DetailWrapper(instance, self)
  File "c:\program files\python37\lib\site-packages\vininfo\details\_base.py", line 20, in __init__
    attr_name, attr_idx = detail.source
TypeError: cannot unpack non-iterable NoneType object
Guillermo
  • 80
  • 1
  • 9

1 Answers1

0

You can force transmission to an empty list:

>>> vin = vininfo.Vin("1NKZXPEX4GJ109010")
>>> vin.details.transmission = []
>>> vin.details.annotate()
OrderedDict([('Body', 'E'), ('Engine', 'Z'), ('Model', 'X'), ('Plant', 'J'), ('Serial', '109010'), ('Transmission', '')])
user4624500
  • 286
  • 1
  • 10
  • Doing this I would lose the data in ".transmission" from the correct ones. The problem is I can't seem to be able to even "check" if ".transmission" has data or not. If it has data everything works, if it doesn't then it explodes on any method used on that attr. Even `hasattr()`fails at it. I was able to fix the source code of that package but that wasn't optimal and decided to drop using it – Guillermo Sep 25 '20 at 17:37