Skip to content

Undefined variable when using generic type parameters (PEP695) #9193

Closed
@Manitary

Description

@Manitary

Bug description

The behaviour described in #9110 is still observable with pylint 3.0.2:

def f[T](a: T) -> T: ...

works fine but T is marked as undefined variable

Configuration

No response

Command used

pylint .\mwe.py

Pylint output

************* Module mwe
mwe.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mwe.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
mwe.py:1:12: E0602: Undefined variable 'T' (undefined-variable)
mwe.py:1:18: E0602: Undefined variable 'T' (undefined-variable)
mwe.py:1:9: W0613: Unused argument 'a' (unused-argument)
mwe.py:1:6: W0612: Unused variable 'T' (unused-variable)

Expected behavior

There should be no E0602, E0602, W0612.

Pylint version

pylint 3.0.2
astroid 3.0.1
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]

OS / Environment

OS: Win32NT (10.0.19045.0)

Additional dependencies

No response

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