-
Notifications
You must be signed in to change notification settings - Fork 196
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
Stop parsing string annotations when no longer in a typing call #546
Conversation
] = set() | ||
self.__in_type_hint: Set[Union[cst.Call, cst.Annotation, cst.Subscript]] = set() | ||
self.__in_annotation_stack: List[bool] = [False] | ||
self.__in_type_hint_stack: List[bool] = [False] | ||
self.__in_ignored_subscript: Set[cst.Subscript] = set() |
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 actually think I can remove __in_ignored_subscript
and implement it by pushing False into __in_annotation_stack
34316b5
to
948bfd8
Compare
I didn't make the suggested change in #491 because this test is expecting that to fail for typing calls: |
I'd be happy to remove those offending tests if that'd make things easier. I think they're just there to document existing behavior. |
948bfd8
to
d842d40
Compare
Codecov Report
@@ Coverage Diff @@
## main #546 +/- ##
=======================================
Coverage 94.77% 94.77%
=======================================
Files 235 235
Lines 23246 23254 +8
=======================================
+ Hits 22032 22040 +8
Misses 1214 1214
Continue to review full report at Codecov.
|
0943a39
to
3dbd5c9
Compare
1ec78be
to
cc98d39
Compare
@@ -851,33 +849,36 @@ def visit_Attribute(self, node: cst.Attribute) -> Optional[bool]: | |||
|
|||
def visit_Call(self, node: cst.Call) -> Optional[bool]: | |||
self.__top_level_attribute_stack.append(None) | |||
self.__in_type_hint_stack.append(False) | |||
self.__in_annotation_stack.append(False) |
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.
Appending to __in_annotation_stack
here was an error. Fixed in #561
Summary
To correct handle these nested function calls I've turned the type hint tracking in the ScopeVisitor into a stack rather than a set.
Test Plan
python -m unittest libcst.metadata.tests.test_scope_provider