Add type annotations to vyper parse.py internals#714
Conversation
|
👋 I've got this PR — here's what I'll handle for you:
Marking it ready and picking reviewers are your call — I'll leave both alone. Drop a comment anytime! |
|
Started — view session to follow along. |
|
All blocking gates are green on |
| return node | ||
|
|
||
| def visit_For(self, node): | ||
| def visit_For(self, node: python_ast.For) -> python_ast.For: |
There was a problem hiding this comment.
The new return annotation -> python_ast.For is inconsistent with the function's actual return: return self.generic_visit(node) on the last line returns python_ast.AST per the new generic_visit annotation on line 211, so mypy will flag this as an incompatible return type. Consider parameterizing generic_visit with a TypeVar (e.g. _AstT) so subclass methods can return their narrow types, or cast(...) the result here.
Severity: low
🤖 Was this useful? React with 👍 or 👎
There was a problem hiding this comment.
Fixed in c6d510a by parameterizing generic_visit with _AstT and casting the super().generic_visit(...) result back to that type. Validation: python -m py_compile vyper/vyper/ast/parse.py; structural annotation check passed. (python -m mypy ... is unavailable here because mypy is not installed.)
Summary
vyper/vyper/ast/parse.pyValidation
python -m py_compile vyper/ast/parse.pyvyper/vyper/ast/parse.pyNotes
python -m pytest tests/unit/ast/test_parser.py tests/unit/ast/test_tokenizer.py tests/unit/ast/test_annotate_and_optimize_ast.pycould not run becausepytestis not installed in the current environmentCryptodependency required by Vyper importsgithub-apiwas unavailable, so this PR was created withgithub-app-apiinsteadPull Request opened by Augment Code | View session