hildogjr / KiCost

Build cost spreadsheet for a KiCad project.
MIT License
519 stars 98 forks source link

TypeError: argument of type 'NoneType' is not iterable #514

Closed hkleen closed 2 years ago

hkleen commented 2 years ago

Issue / Problem report

Running KiCost on some BOMs causes the following Error and traceback:

Traceback (most recent call last):
  File "/usr/local/bin/kicost", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/kicost/__main__.py", line 417, in main
    main_real()
  File "/usr/local/lib/python3.8/dist-packages/kicost/__main__.py", line 407, in main_real
    kicost(in_file=args.input, eda_name=args.eda,
  File "/usr/local/lib/python3.8/dist-packages/kicost/kicost.py", line 225, in kicost
    query_part_info(parts, dist_list, currency)
  File "/usr/local/lib/python3.8/dist-packages/kicost/kicost.py", line 77, in query_part_info
    get_dist_parts_info(parts, dist_list, currency)
  File "/usr/local/lib/python3.8/dist-packages/kicost/distributors/__init__.py", line 46, in get_dist_parts_info
    distributor_class.get_dist_parts_info(parts, dist_list, currency)
  File "/usr/local/lib/python3.8/dist-packages/kicost/distributors/distributor.py", line 87, in get_dist_parts_info
    api.query_part_info(parts, distributors, currency)
  File "/usr/local/lib/python3.8/dist-packages/kicost/distributors/api_partinfo_kitspace.py", line 322, in query_part_info
    api_partinfo_kitspace.get_part_info(queries[slc], query_parts[slc], distributors, currency, query_part_stock_code[slc])
  File "/usr/local/lib/python3.8/dist-packages/kicost/distributors/api_partinfo_kitspace.py", line 182, in get_part_info
    part.update_specs({sp['key']: (sp['key'], sp['value']) for sp in result['specs']})
  File "/usr/local/lib/python3.8/dist-packages/kicost/__init__.py", line 46, in update_specs
    if value not in old_value:
TypeError: argument of type 'NoneType' is not iterable

Example BOM: Bom.zip

Command: kicost -w -i kcost_issue.xml --debug=8

Output: output.txt

Version used KiCost v1.1.6 on Ubuntu 20.04.4

set-soft commented 2 years ago

Thanks @hkleen ! I didn't see any case where an spec was returned by KitSpace without a value. The above patch excludes empty specs.