anentropic / python-waterloo

A cli tool to convert type annotations found in 'Google-style' docstrings into mypy py2 type comments (and from there into py3 type annotations).
2 stars 1 forks source link

Use parso scopes to correctly determine if non top level types are in scope #15

Open anentropic opened 4 years ago

anentropic commented 4 years ago

Currently we find all the imports and class defs in the module and treat them as all "in scope" for any annotated function

So there are some edge cases where we would fail to auto-add an import because we treated a non-top-level classdef or import elsewhere in the module as in-scope, whne it wasn't

It looks like Parso is able to keep track of variable scopes in its parse tree... so we could potentially "get this right", just at the cost of even more complication in our auto-import logic...