Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental/use standalone visitor #309

Merged
merged 4 commits into from
Nov 16, 2023
Merged

Experimental/use standalone visitor #309

merged 4 commits into from
Nov 16, 2023

Conversation

bzoracler
Copy link
Contributor

@bzoracler bzoracler commented Nov 16, 2023

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) on mypy==1.7.0. The style (including explicit re-export of the nodes, @functools.singledispatch, nothing under TYPE_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), not node.accept(visitor)) because mypy nodes can't accept visitors that are not subclassed from mypy's own visitors (mypyc fails type incompatibilities at runtime), and you can't subclass mypy.traverser.TraverserVisitor with the mypy==1.7.0 change.

Setting this as a draft PR - feel free to merge, change, and/or discard as appropriate.

@bzoracler bzoracler marked this pull request as ready for review November 16, 2023 17:18
@bzoracler
Copy link
Contributor Author

Upgraded status as it looks like it's a release blocker (https://qa.debian.org/excuses.php?package=mypy)

@dosisod
Copy link
Owner

dosisod commented Nov 16, 2023

Thanks! This looks good as is, so I'll go ahead and merge it. I'll make sure to publish a release by EOD.

Closes #305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants