You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have the following code, that started failing type checks for mypy0.950. From the error I assume, it is probably more an issue of attrs than mypy itself. Feel free to correct me. Also, if I change @attr.s() to @dataclass it works just fine. I have found one change in mypy0.950 that can be related to this: python/mypy#12656
Thanks for any help
Code:
fromtypingimportGeneric, TypeVarimportattrT=TypeVar("T")
@attr.s()classInner(Generic[T]):
data: T=attr.ib()
@attr.s()classOuter(Generic[T]):
inner: Inner[T] =attr.ib()
@attr.s()classSpecificOuter(Outer[T]):
passdeftest() ->None:
inner=Inner[int](data=0)
Outer[int](inner=inner) # OKSpecificOuter[int](inner=inner) # Not OK
Error:
Argument "inner" to "SpecificOuter" has incompatible type "Inner[int]"; expected "Inner[T]" mypy(error)
From the error I assume, it is probably more an issue of attrs than mypy itself.
I'm not sure why you would think that. Almost all of relevant type logic lives in Mypy's attrs pluging. Looks like they broke subclassing of Generic[T] and only fixed it for dataclasses. :(
You could’ve kept it open to prevent more bug reports, but it looks like Jukka it already working on a fix so hopefully this will be a non-issue real soon. 🤞
Hi,
I have the following code, that started failing type checks for
mypy
0.950
. From the error I assume, it is probably more an issue ofattrs
thanmypy
itself. Feel free to correct me. Also, if I change@attr.s()
to@dataclass
it works just fine. I have found one change inmypy
0.950
that can be related to this: python/mypy#12656Thanks for any help
Code:
Error:
Versions:
mypy: 0.950
attrs: 21.4.0
python: 3.8.10
OS: Ubuntu 20.04
The text was updated successfully, but these errors were encountered: