- Notifications
You must be signed in to change notification settings - Fork263
-
In Example: fromtypingimportIterable,overload,NoReturn@overloaddeffunc(s:str)->NoReturn: ...@overloaddeffunc(s:Iterable[str])->list[str]: ...deffunc(s:Iterable[str])->list[str]:ifisinstance(s,str):raiseException("plain string not accepted")else:x= [vforvins]returnx# reveal_type(func("abc"))func("abc")v=3+4func({"a":1,"b":2}) This code will raise an exception as expected. If I uncomment the Ideally, the type checker would show that |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 3 replies
-
Linking#256 for related discussion |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I think this may be a configuration issue.mypy-playground,pyright-playground One caveat is that they only raise the unreachable on the next line, not on the line that produces the |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes, for Take this simple example: deffoo()->NoReturn:raiseNotImplementedErrorfoo() Shouldn't the type checker say that |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
A function signature with a What you're looking for is a way to mark the overload as an error condition, which would require a new mechanism and an update to the existingoverload call evaluation specification. There has beensome discussion of this previously, but no one has driven a concrete proposal. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I added an idea there - maybe it will get some traction. |
BetaWas this translation helpful?Give feedback.