-
Notifications
You must be signed in to change notification settings - Fork 771
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
False "variable is not accessed" message #107
Comments
Thanks for the bug report. If you turn on the type checker (i.e. set "python.analysis.typeCheckingMode" to "basic"), you'll see that Pylance finds a bug in the above code. The variable That said, Pylance should not mark the symbol |
This will be fixed in the next version of Pylance & Pyright. |
Thank you for your fast reply. If I use the following code, pylance does not think that class Test:
def func(self):
try:
1 / 0
except ZeroDivisionError as exc:
string = "A string"
raise exc.__class__(string) |
The problem wasn't reported for the second version because Pylance assumes that symbols within the module-level scope should never be marked as "not accessed" because they might be improted by other modules. The exception to this rule is if the name of the symbol starts with an underscore, which tells Pylance that it should be private to the module. So if you had named your variable |
This issue has been fixed in version 2020.7.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202072-15-july-2020 |
I'd like to report this/similar issue with version Code to reproduceclass WhateverClass:
def some_method(self):
some_variable = 123
return type('Whatever', (object,), {
'whatever': some_variable,
}) Pylance version
Using
|
@smuuf, thanks for the bug report. This is a different issue that is specific to the |
Environment data
Expected behaviour
No message at variable
string
in line 6, just like in line 13.Actual behaviour
Variable
msg
in Test.func is marked as"string" is not accessed
, while it is clearly being accessed in the next line.Code Snippet / Additional information
The text was updated successfully, but these errors were encountered: