Skip to content

Undefined Variable Generic Class (PEP695) #10038

@jfulbricht

Description

@jfulbricht

Bug Description:

#9195 appears to have fixed #9193 for generic functions but not for generic classes:

"""
Module Docstring
"""

from collections.abc import Callable

class CallableWrapper[**P, T]:
    """Class Docstring"""

    def __init__(self, __callable: Callable[P, T]) -> None:
        self.callable = __callable

    def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
        return self.callable(*args, **kwargs)

Command Used

pylint pylint_undefined_variable.py

Pylint Output

************* Module pylint_E0602
************* Module pylint_undefined_variable
pylint_undefined_variable.py:10:44: E0602: Undefined variable 'P' (undefined-variable)
pylint_undefined_variable.py:10:47: E0602: Undefined variable 'T' (undefined-variable)
pylint_undefined_variable.py:13:30: E0602: Undefined variable 'P' (undefined-variable)
pylint_undefined_variable.py:13:48: E0602: Undefined variable 'P' (undefined-variable)
pylint_undefined_variable.py:13:61: E0602: Undefined variable 'T' (undefined-variable)
pylint_undefined_variable.py:7:0: R0903: Too few public methods (1/2) (too-few-public-methods)

Expected Behavior

No E0602: Undefined Variable errors.

Pylint Version

pylint 3.3.1
astroid 3.3.5
Python 3.12.7 (heads/main:466d8c8, Oct 15 2024, 03:59:42) [GCC 13.3.0]

OS/Environment

Rocky Linux 8

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