pylint icon indicating copy to clipboard operation
pylint copied to clipboard

False positive: possibly-used-before-assignment doesn't understand and-ed contions

Open skirpichev opened this issue 1 month ago • 7 comments

Bug description

# pylint: disable=missing-module-docstring,invalid-name
a = bool(input())
b = bool(input())

if a:
    c = 123

if a and b:
    print(c)  # report possibly-used-before-assignment

if a:
    c += 1  # ok

Configuration

No response

Command used

pylint bug.py

Pylint output

************* Module bug
bug.py:9:10: E0601: Using variable 'c' before assignment (used-before-assignment)

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

Expected behavior

No errors

Pylint version

pylint 3.2.2
astroid 3.2.2
Python 3.11.3+ (heads/3.11:9fbb614c4e, Apr 29 2023, 14:18:05) [GCC 10.2.1 20210110]

OS / Environment

No response

Additional dependencies

No response

skirpichev avatar May 21 '24 06:05 skirpichev