-
-
Couldn't load subscription status.
- Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codeneeds discussionpriority-0-hightopic-dataclasses
Description
mypy 0.620, --strict.
Sample code:
import abc
from dataclasses import dataclass
@dataclass # error: Only concrete class can be given where "Type[Abstract]" is expected
class Abstract(metaclass=abc.ABCMeta):
a: str
@abc.abstractmethod
def c(self) -> None:
pass
@dataclass
class Concrete(Abstract):
b: str
def c(self) -> None:
pass
instance = Concrete(a='hello', b='world')Note that this error only occurs if at least one abstract method is defined on the abstract class. Removing the abstract method c (or making it non-abstract) makes the error go away.
languitar, antdking, csabaszilveszter, saulshanabrook, glyph and 139 morealdanor, Veganveins, ET-Chan, rolyp, agronskiy and 4 moreYobmod, schneiderfelipe, marcellovictorino, chey, aucampia and 1 more
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codeneeds discussionpriority-0-hightopic-dataclasses