-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
Describe the bug
When a type annotation is an exact string match for a class name defined elsewhere in the file, it is falsely reported as a circular reference.
To Reproduce
See code below for a minimal repro case.
Expected behavior
PEP-0563 indicates that I should expect that the type hint would only match names in the module scope.
See https://www.python.org/dev/peps/pep-0563/#implementation
Screenshots or Code
class A:
A: 'str'
class B:
A: 'A'The above code produces the following error:
bad_match.py:5:9 - error: Type of "A" could not be determined because it refers to itself (reportGeneralTypeIssues)
This should correctly evaluate to class A rather than the class member A
VS Code extension or command-line
Running pyright 1.1.191 on the command line.
Additional context
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working