pylint icon indicating copy to clipboard operation
pylint copied to clipboard

False positive `unused-import` when using union of types inside quotes

Open evgeny-fuse opened this issue 1 year ago • 0 comments

Bug description

If the type is used inside of quotes and combined with other types using |, pylint doesn't count it as a type usage, and reports a warning.

from typing import List
from dataclasses import dataclass

@dataclass
class A:
    f: "List[int] | None"

Configuration

No response

Command used

pylint quoted.py

Pylint output

************* Module quoted quoted.py:2:0: W0611: Unused List imported from typing (unused-import)


Your code has been rated at 7.50/10 (previous run: 2.50/10, +5.00)

Expected behavior

Pylint doesn't output error

Pylint version

pylint 3.3.1 astroid 3.3.5 Python 3.12.4 (main, Jun 25 2024, 07:38:25) [Clang 15.0.0 (clang-1500.3.9.4)]

OS / Environment

macOS, 14.4

Additional dependencies

No response

evgeny-fuse avatar Oct 17 '24 21:10 evgeny-fuse