Experimental/use standalone visitor #309
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an experimental PR to use a standalone imitation of
mypy.visitor.TraverserVisitor
, allowing reversion of the recent pinning of mypy to <1.7.The visitor module
traverser.py
is produced from generated code (not handwritten) onmypy==1.7.0
. The style (including explicit re-export of the nodes,@functools.singledispatch
, nothing underTYPE_CHECKING
blocks even though the imports aren't used at runtime) is deliberate to allow the visitor to be compiled by mypyc if you wish (which has a lot of quirks, and is not fully compatible with standard Python in my experience).The visitor has a different API (
visitor.accept(node)
, notnode.accept(visitor)
) because mypynode
s can'taccept
visitors that are not subclassed from mypy's own visitors (mypyc fails type incompatibilities at runtime), and you can't subclassmypy.traverser.TraverserVisitor
with themypy==1.7.0
change.Setting this as a draft PR - feel free to merge, change, and/or discard as appropriate.