dropbox / pyannotate

Auto-generate PEP-484 annotations
Apache License 2.0
1.42k stars 59 forks source link

Crash in collect_types prep_args #13

Closed jabdoa2 closed 6 years ago

jabdoa2 commented 6 years ago

When collecting types on Ubuntu 16.04 with Python 3.5 on the partially annotated Mission Pinball Framework codebase (https://github.com/missionpinball/mpf/), I get this error:

  File "/usr/local/lib/python3.5/dist-packages/pyannotate_runtime/collect_types.py", line 719, in _trace_dispatch
    resolved_types = prep_args(arg_info)
  File "/usr/local/lib/python3.5/dist-packages/pyannotate_runtime/collect_types.py", line 474, in prep_args
    resolved_type = resolve_type(arg_info.locals[arg])
KeyError: 'source'

Changing if not isinstance(arg, (list, dict)): to if not isinstance(arg, (list, dict)) and arg in arg_info.locals: fixes this for me. Don't know it that is a proper solution.

gvanrossum commented 6 years ago

Can you please submit a PR with the fix so I can review and test it?

gvanrossum commented 6 years ago

Closing as duplicate of #21 (because the latter shows a small example).