-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Never
inferred in complex situation with variadic callable protocol
#16522
Comments
This is surprisingly tedious to fix (since mixing |
@ilevkivskyi any update on this? I would really, really like Trio and AnyIO to give precise types for their |
OK, I will make this easier for you. You could have just said something like: "As a data point this use case is very important for Trio and AnyIO" and I would have gladly raised priority, but no, for some reason you are using except. I am therefore not going to work on this until this will be last open issue on the tracker. |
I'm sorry Ivan; clearly I've miscommunicated pretty badly. This issue is indeed pretty important to Trio, e.g. it's the last thing keeping our stubs package alive and that's all I meant by "except". Supporting mypy matters enough to me to keep paying that maintenance cost if needed. |
Bug Report
Mypy is inferring a
Never
in a bit of a complicated setup involvingTypeVarTuple
,__call__
protocols and a regularTypeVar
. If an annotated assignment is present it is able to check that they match. But when a bare call is done, it infersNever
and always produces an error. This is a simplified version of Trio'sNursery.start()
async spawn method, which I'm trying to type. (Seesrc/trio/_core/_run.py
.) I simplified it a little, removing an overload and making it synchronous.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=31be4208e294eb6c5cbc7390f4a836f4
Expected Behavior
Ideally Mypy would be able to propagate the typevar in
TaskStatus
to determine the return type, and verify that appropriate types were passed for*args
.Actual Behavior
The first error is correct, showing that Mypy can understand the types somewhat. But in the second case it's strangely producing
Never
, when it should really be effectivelyAny
- the type is unused so it doesn't matter what it is.Your Environment
1.7.0
, also triedmaster
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: