Skip to content

used-before-assignment false positive for import nodes under elif after TYPE_CHECKING #8437

Closed
@jacobtylerwalls

Description

@jacobtylerwalls

Bug description

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    pass
elif 42:
    import math


print(math)

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
a.py:5:5: W0125: Using a conditional statement with a constant value (using-constant-test)
a.py:9:6: E0601: Using variable 'math' before assignment (used-before-assignment)

--------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 10.00/10, -10.00)

Expected behavior

************* Module a
a.py:5:5: W0125: Using a conditional statement with a constant value (using-constant-test)

--------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 10.00/10, -10.00)

Pylint version

pylint 3.0.0a6
astroid 2.16.0dev0
Python 3.11.0

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

C: used-before-assignmentIssues related to 'used-before-assignment' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions