-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Variable used before definition #3598
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
Comments
I have a similar issue with my Python. Issues disappear if you reload window, but reappear if I make even the slightest edit to the code written. Sometimes they appear as I type (e.g. I type "return True" and issues are " 're' used before definition", " 'ret' used before definition" and so on). Issue appears to occur more in longer files. |
@yehorb Could you create a minimal Github repo with a reproducible error? It will help a lot in fixing this issue. In my case, this happens because of |
@yehorb Awesome, thanks! Now it's just waiting for a maintainer to triage this issue. 🤷♂️ |
I'm encountering a very similar problem with class variable type annotations. class TestClass:
instance_var: str
def __init__(self) -> None:
self.instance_var = "" produces
By adding a typed class variable, the error disappears (no problems are detected): from typing import ClassVar
class TestClass:
instance_var: str
class_var: ClassVar[int] = 0
def __init__(self) -> None:
self.instance_var = "" Omitting the type annotation on the class variable will cause the previous error on the instance variable to show up again: class TestClass:
instance_var: str
class_var = 0
def __init__(self) -> None:
self.instance_var = "" produces
|
@phwh reported in microsoft/python-language-server#399 . |
@millsyman please report on the upstream issue. |
Original issue is fixed upstream (microsoft/python-language-server#475) |
Uh oh!
There was an error while loading. Please reload this page.
Environment data
Expected behaviour
When running provided code snippet there should be no warning.
Actual behaviour
A warning is generated:
'fallbackName' used before definition
Additional Info
This does not happen when type hinting is removed:
Steps to reproduce:
python3 -m venv new/venv
.new/index.py
.Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
)The text was updated successfully, but these errors were encountered: