-
- Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
I'm explicitly typing a variable with Type
(or type
) and mypy thinks I should not subclass it.
To Reproduce
from typing import Type class Base: ... def get_base() -> Type[Base]: return Base BaseAlias: Type[Base] = get_base() class Derived(BaseAlias): ...
Expected Behavior
There should be no error. I'm subclassing a type, which is ok. Furthermore, mypy has the information that it's a type so subclassing should not be questioned.
Actual Behavior
footypes.py:11: error: Variable "footypes.BaseAlias" is not valid as a type footypes.py:11: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases footypes.py:11: error: Invalid base class "BaseAlias" Found 2 errors in 1 file (checked 1 source file)
Same behavior if specifying BaseAlias: type = get_base()
instead.
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.9.0
- Operating system and version:
python:3.9
docker image
Avasam
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong