Describe the bug
Pyright reports false error for codes like below.
# a.py
a = 0
class MyClass:
a = a # <- Pyright says "'a' is unbound"
print(MyClass.a)
Pyright says 'a' is unbount, even though Python can run the code without any problem.
$ python a.py
0
$ npx pyright a.py
npx: installed 1 in 1.613s
typingsPath /Users/michitaro/Desktop/typings is not a valid directory.
Searching for source files
Found 1 source file
/Users/michitaro/Desktop/a.py
5:9 - error: 'a' is unbound
5:9 - error: 'a' is unbound
2 errors, 0 warnings
Completed in 1.288sec
To Reproduce
Expected behavior
Pyright does not report any error for the code.
VS Code extension or command-line
Both VS Code extension and command-line. The version of the extension is 1.1.26.
Thanks for the bug report. This will be fixed in the next published version of Pyright.
This is now fixed in Pyright 1.1.27, which I just published.
Thank you very much for the ultra fast fix!