Skip to content

Undefined Variable Generic Class (PEP695) #10038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jfulbricht opened this issue Oct 21, 2024 · 1 comment
Closed

Undefined Variable Generic Class (PEP695) #10038

jfulbricht opened this issue Oct 21, 2024 · 1 comment
Labels
Duplicate 🐫 Duplicate of an already existing issue python 3.12

Comments

@jfulbricht
Copy link

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

@jacobtylerwalls
Copy link
Member

Duplicate of #9335

@jacobtylerwalls jacobtylerwalls marked this as a duplicate of #9335 Oct 22, 2024
@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2024
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue python 3.12 labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue python 3.12
Projects
None yet
Development

No branches or pull requests

2 participants