-
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
fix is_annotation for types used in classdef base and assign value #406
Conversation
libcst/metadata/scope_provider.py
Outdated
@@ -647,6 +647,7 @@ def __init__(self, provider: "ScopeProvider") -> None: | |||
Union[cst.Call, cst.Annotation, cst.Subscript] | |||
] = set() | |||
self.__in_ignored_subscript: Set[cst.Subscript] = set() | |||
self.__ignore_annotation: bool = 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.
This should probably be a stack or a counter instead of a simple bool to keep track of nesting. Let's add a nested test case while we're at it.
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.
The logic in visit_Call
also needs to be updated.
The Aug of TypeVar and NewType are not actually Annotation.
libcst/metadata/scope_provider.py
Outdated
def visit_Assign_value(self, node: cst.Assign) -> None: | ||
self.__ignore_annotation += 1 | ||
|
||
def leave_Assign_value(self, node: cst.Assign) -> None: | ||
self.__ignore_annotation -= 1 | ||
|
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.
Handle Assign differently doesn't seem right.
We should only consider the is_annotation for access in Annotation node (__in_annotation
already takes case that).
Codecov Report
@@ Coverage Diff @@
## master #406 +/- ##
==========================================
- Coverage 94.11% 94.11% -0.01%
==========================================
Files 231 231
Lines 22427 22449 +22
==========================================
+ Hits 21108 21128 +20
- Misses 1319 1321 +2
Continue to review full report at Codecov.
|
Summary
fix is_annotation for types used in classdef base and assign value
discussion
Test Plan
tox -e py37
tox -e autofix