-
-
Notifications
You must be signed in to change notification settings - Fork 805
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
feat: require type annotations for loop variables #3596
feat: require type annotations for loop variables #3596
Conversation
…/loop_var_annotation2
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3596 +/- ##
==========================================
+ Coverage 84.23% 84.25% +0.02%
==========================================
Files 92 92
Lines 13034 13073 +39
Branches 2919 2916 -3
==========================================
+ Hits 10979 11015 +36
- Misses 1636 1640 +4
+ Partials 419 418 -1 ☔ View full report in Codecov by Sentry. |
vyper/ast/parse.py
Outdated
@@ -82,7 +83,7 @@ def parse_to_ast_with_settings( | |||
module = vy_ast.get_node(py_ast) | |||
assert isinstance(module, vy_ast.Module) # mypy hint | |||
|
|||
return settings, module | |||
return settings, module, loop_var_annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think instead of passing around loop_var_annotations
everywhere we should just tag it on the AST during the annotate_vyper_ast
portion of ast parsing.
vyper/semantics/analysis/module.py
Outdated
@@ -485,13 +485,13 @@ def _load_import_helper( | |||
|
|||
|
|||
def _parse_and_fold_ast(file: FileInput) -> vy_ast.VyperNode: | |||
ret = vy_ast.parse_to_ast( | |||
ast = vy_ast.parse_to_ast( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess since folding isn't performed any longer we can kind of skip the intermediate variable assignment (and rename the function!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just reverted the change since it's not relevant to this PR
vyper/ast/parse.py
Outdated
loop_var_annotations[k]["vy_ast"] = loop_var_vy_ast | ||
del loop_var_annotations[k]["parsed_ast"] | ||
|
||
module._metadata["loop_var_annotations"] = loop_var_annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we need to attach this into the metadata tbh. this should all be handled before analysis, and ideally before we even get to vyper AST construction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can accomplish all this just with adding a visit_For
into the visitor in this file
roll back some stylistic changes to error messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work. thanks!
What I did
Fix #3475, #3441
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture