pylint-dev/pylint

False positive: Undefined variable '__annotations__' in class body

dnpetrov opened this issue · 1 comments

Bug description

class Test:
    a: int
    b: float
    c: str

    __slots__ = tuple(__annotations__)

Configuration

No response

Command used

pylint ./test.py

Pylint output

************* Module test
test.py:6:22: E0602: Undefined variable '__annotations__' (undefined-variable)

Expected behavior

No error.

Pylint version

pylint 3.0.3
astroid 3.0.3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

OS / Environment

Ubuntu 22.04

Additional dependencies

No response

Thank you for the report but I will close it since there already exists another issue which captures this scenario: #7126 (comment)