-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
It seems that mypy does not allow to inherit from a parameter when creating a function on the fly.
To Reproduce
from typing import Type
def f(cls: Type) -> Type:
class A(cls):
...
return A
>>>file.py:6: error: Variable "cls" is not valid as a type [valid-type]
>>>file.py:6: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
>>>file.py:6: error: Invalid base class "cls" [misc]
Expected Behavior
Mypy should not complain
Actual Behavior
Mypy complain and say
>>>file.py:6: error: Variable "cls" is not valid as a type [valid-type]
>>>file.py:6: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
>>>file.py:6: error: Invalid base class "cls" [misc]
Your Environment
- Mypy version used:`0.990
- Python version used: 3.9.10
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong