Open finite-state-machine opened 1 year ago
Note that this is specific to __new__
, other (explicit) class methods work correctly. I didn't check, but it may be caused by https://github.com/python/mypy/pull/12590 cc @JukkaL FWIW PR looks correct, probably it just exposes some old missing special casing for __new__
. Likely should be an easy fix.
FWIW I've confirmed this issue persists on the development version of mypy (2023-06-26).
It looks like @kourbou fixed this with 1dd8e7f
(#16670) when they fixed #16668:
commit 1dd8e7fe6
Author: Kouroche Bouchiat <kourbou@users.noreply.github.com>
Date: Sun Dec 17 21:32:57 2023 +0100
Substitute type variables in return type of static methods (#16670)
`add_class_tvars` correctly instantiates type variables in the return
type for class methods but not for static methods. Check if the analyzed
member is a static method in `analyze_class_attribute_access` and
substitute the type variable in the return type in `add_class_tvars`
accordingly.
Fixes #16668.
Thanks, @kourbou!
Is it worth adding a test for this case?
Bug Report
Consider the following code [mypy-play.net]:
To Reproduce
See above.
Actual Behavior
Expected Behavior
There should be no errors. (In fact, this worked correctly until mypy 0.950.)
The first and third errors make little sense since
Type[Evens[T]]
is a special case ofType[Parent[T]]
.The second and fourth errors make even less sense, since
Sequence[T]
is exactly the same asSequence[T]
.If there is actually some kind of problem here, the error messages need to be much more helpful than they currently are.
Your Environment
mypy.ini
(and other config files): N/A