-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
When using a TypeVar from an abstract class, and the abstract class additionally inherits from some integrated types (I found dict, int, str, set; not float), mypy incorrectly alarms about instantiating an abstract class.
To Reproduce
from abc import ABC, abstractmethod
from typing import TypeVar, Type
class User(ABC, dict): # removing dict makes mypy happy
@abstractmethod
def method(self):
...
class BasicUser(User):
def method(self):
print('basic')
U = TypeVar('U', bound=User)
def new_user(user_class: Type[U]) -> U:
user = user_class()
return user
joe = new_user(BasicUser)Expected Behavior
It should not report an error, as it does not when inheriting from another class or just ABC.
Actual Behavior
test.py:20: error: Cannot instantiate abstract class "User" with abstract attribute "method" [abstract]
Your Environment
- Mypy version used: 0.990
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.10.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong