Skip to content

Add type annotations to vyper parse.py internals#714

Draft
augmentcode[bot] wants to merge 2 commits into
mainfrom
michaelos443/annotate-parse-types
Draft

Add type annotations to vyper parse.py internals#714
augmentcode[bot] wants to merge 2 commits into
mainfrom
michaelos443/annotate-parse-types

Conversation

@augmentcode
Copy link
Copy Markdown

@augmentcode augmentcode Bot commented May 26, 2026

Summary

  • add explicit annotations for previously untyped local variables in vyper/vyper/ast/parse.py
  • add return and parameter annotations for internal helper functions and visitor methods in the same file
  • keep the change behavior-preserving, with only minor type-safety assertions around existing assumptions

Validation

  • python -m py_compile vyper/ast/parse.py
  • structural AST check confirming there are no remaining untyped defs in vyper/vyper/ast/parse.py

Notes

  • python -m pytest tests/unit/ast/test_parser.py tests/unit/ast/test_tokenizer.py tests/unit/ast/test_annotate_and_optimize_ast.py could not run because pytest is not installed in the current environment
  • direct runtime smoke checks could not run because the current environment is missing the Crypto dependency required by Vyper imports
  • manual-session GitHub attribution is misconfigured here: github-api was unavailable, so this PR was created with github-app-api instead

Pull Request opened by Augment Code | View session

@augmentcode
Copy link
Copy Markdown
Author

augmentcode Bot commented May 26, 2026

PR Author Agent

👋 I've got this PR — here's what I'll handle for you:

  • Review feedback — implement suggestions, answer questions, fix what comes up
  • CI failures — I get pinged when checks fail and try to fix them
  • Merge conflicts — bring the PR back up to date when it falls behind
  • Merge gates — watch CI, reviews, and verification
  • Ping you the moment it's ready to merge

Marking it ready and picking reviewers are your call — I'll leave both alone.

Drop a comment anytime!

@augmentcode
Copy link
Copy Markdown
Author

augmentcode Bot commented May 27, 2026

Deep Code Review Agent🐛

Started — view session to follow along.

Copy link
Copy Markdown
Author

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

Review completed with 0 suggestions.

@augmentcode
Copy link
Copy Markdown
Author

augmentcode Bot commented May 27, 2026

PR Author Agent

All blocking gates are green on b50cbfb68f3651c5adde1dd0ba22e8bb8dcb8a64 — ready to flip to ready-for-review whenever you are. Reply mark ready here, or use the Ready for review button on GitHub.

Copy link
Copy Markdown
Author

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

Review completed with 1 suggestion.

Comment thread vyper/vyper/ast/parse.py
return node

def visit_For(self, node):
def visit_For(self, node: python_ast.For) -> python_ast.For:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👎

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Author Agent

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.)

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.

1 participant