Skip to content

Yet another false positive E0601 used-before-assignment, now for type hints #8110

Closed
@zEdS15B3GCwq

Description

@zEdS15B3GCwq

Bug description

Issue

Code:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from numpy import ndarray

a: ndarray # E0601 here
b=ndarray()

Note that only the type hint was flagged by the error, the assignment was not.

Related to

#7574 (may be fixed by #8071)
#7979 (fixed in #7980)
#7368 (fixed by #7360)
However, none of these seem to cover type hints.

Configuration

No response

Command used

pylint --disable=missing-module-docstring .\pylint_test.py

Pylint output

************* Module pylint_test
pylint_test.py:6:3: E0601: Using variable 'ndarray' before assignment (used-before-assignment)

Expected behavior

No issues for the type hint.

Pylint version

pylint 2.15.10
astroid 2.13.3
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]

OS / Environment

Windows 11 x64 21H2

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions