И это всё МОЁ

Вот в таком MWE:

from typing import Generic, TypeVar

import dataclasses

T = TypeVar('T')


@dataclasses.dataclass()
class A(Generic[T]):
attr: T


A(attr=0) # OK!


@dataclasses.dataclass()
class B(A[float]):
...


B(attr=float(0)) # Argument "attr" to "B" has incompatible type "float"; expected "T"

mypy ругается на последнюю строчку ошибкой «Argument „attr“ to „B“ has incompatible type „float“; expected „T“. Но ведь класс B уточнил, что T - это float, так что все должно быть нормально.








 , , , ,