8000 conditional import X.Y causes false positive possibly-used-before-assignment · Issue #10081 · pylint-dev/pylint · GitHub
[go: up one dir, main page]

Skip to content
conditional import X.Y causes false positive possibly-used-before-assignment #10081
@jwilk

Description

@jwilk

Bug description

if input():
    import os.path
else:
    os = None
if os:
    pass

Command used

$ pylint -E condimport.py 

Pylint output

condimport.py:5:3: E0606: Possibly using variable 'os' before assignment (possibly-used-before-assignment)

Expected behavior

The os variable is set in both branches, so no error should be reported.

Pylint version

pylint 3.3.1
astroid 3.3.5
Python 3.13.0 (main, Oct  8 2024, 08:51:27) [GCC 9.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0