-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Wrong Signature for singledispatch'ed functions/methods #101602
Comments
There's a similar issue with |
@arhadthedev I'm removing the "expert-typing" label since this issue isn't really about Python's static typing system (static type checkers make no use of |
@AlexWaygood, thanks for the reference, clearly I've wrong keywords to search. Probably, you may consider this as a duplicate. But I think, that the second part of issue (updated text, i.e. POSITIONAL_OR_KEYWORD vs POSITIONAL_ONLY kind of parameter) is not covered by #89263. |
It wasn't my intent to imply that this was a duplicate; I was just pointing you to an earlier discussion on related themes that I thought you might find interesting! |
An example:
I would expect here something like
<Signature (x: int | str) -> int | str>
(i.e. union of types for returned value, same for argument) or an exception.I'm not sure that the first option is on the table: more accurately this situation fits to case of multiple function signatures (like we have in the stdlib e.g. for the min/max). But the current signature() output is misleading.
UPD: In fact, the Signature must be like
<Signature (x: int | str, /) -> int | str>
, because:Or we can make singledispatch'ed function to be with a positional-only argument iff argument names for different overloaded implementations are different.
PS: Inspired by https://discuss.python.org/t/signatures-a-call-to-action/23580
The text was updated successfully, but these errors were encountered: