Skip to content
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

Detect mix of generic type parameters and Generic subclass #15620

Open
ntBre opened this issue Jan 20, 2025 · 2 comments · May be fixed by #15841
Open

Detect mix of generic type parameters and Generic subclass #15620

ntBre opened this issue Jan 20, 2025 · 2 comments · May be fixed by #15841
Assignees
Labels
accepted Ready for implementation rule Implementing or modifying a lint rule

Comments

@ntBre
Copy link
Contributor

ntBre commented Jan 20, 2025

>>> from typing import TypeVar
>>> T = TypeVar("T")
>>> class Foo[S](Generic[T]): ...
... 
Traceback (most recent call last):
  File "<python-input-13>", line 1, in <module>
    class Foo[S](Generic[T]): ...
  File "<python-input-13>", line 1, in <generic parameters of Foo>
    class Foo[S](Generic[T]): ...
  File "/Users/alexw/.pyenv/versions/3.13.1/lib/python3.13/typing.py", line 1279, in _generic_init_subclass
    raise TypeError(
        "Cannot inherit from Generic[...] multiple times.")
TypeError: Cannot inherit from Generic[...] multiple times.

Originally posted by @AlexWaygood in #15565 (comment)

@ntBre ntBre added the rule Implementing or modifying a lint rule label Jan 20, 2025
@AlexWaygood AlexWaygood added the accepted Ready for implementation label Jan 21, 2025
@InSyncWithFoo
Copy link
Contributor

@ntBre Do you intend to work on this? If not, I can take it.

@ntBre
Copy link
Contributor Author

ntBre commented Jan 30, 2025

Go for it! Thanks for checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants