Skip to content
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

used-before-assignment false positive for type alias #9815

Open
nickdrozd opened this issue Jul 20, 2024 · 0 comments
Open

used-before-assignment false positive for type alias #9815

nickdrozd opened this issue Jul 20, 2024 · 0 comments
Labels
C: used-before-assignment Issues related to 'used-before-assignment' check False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation python 3.12 typing

Comments

@nickdrozd
Copy link
Collaborator

Bug description

type IntOrX = int | X

class X:
    pass

Configuration

No response

Command used

pylint --py-version=3.12 asdf.py

Pylint output

asdf.py:1:20: E0601: Using variable 'X' before assignment (used-before-assignment)

Expected behavior

No warning

The value of the type alias is evaluated in the annotation scope. It is not evaluated when the type alias is created, but only when the value is accessed through the type alias’s value attribute (see Lazy evaluation). This allows the type alias to refer to names that are not yet defined.

https://docs.python.org/3/reference/simple_stmts.html#the-type-statement

Pylint version

pylint 3.3.0-dev0
astroid 3.3.0-dev0
Python 3.12.3

OS / Environment

No response

Additional dependencies

No response

@nickdrozd nickdrozd added typing False Positive 🦟 A message is emitted but nothing is wrong with the code C: used-before-assignment Issues related to 'used-before-assignment' check labels Jul 20, 2024
@jacobtylerwalls jacobtylerwalls added python 3.12 Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: used-before-assignment Issues related to 'used-before-assignment' check False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation python 3.12 typing
Projects
None yet
Development

No branches or pull requests

2 participants