How to properly call an overloaded function/method with parameter type in union? #782
Unanswered
Azureblade3808
asked this question in
Q&A
Replies: 1 comment 1 reply
-
See this issue for additional context. You could define another overload for @overload
def f0(x: Union[A, B]) -> Union[A, B]:
... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Title of this post could be inaccurate, so feel free to change it.
Now, see code below:
I'm pretty sure that in implementation of
f1
, callingf0(x)
is valid, no matter whetherx
is an instance of eitherA
orB
.I'm also pretty sure that the type decision could become much more complicated if there were more than one simple parameter, therefore I won't consider such behavior as a bug.
Adding some type-checks could mute the reported error, but it would harm the running efficiency.
So, are there some other good ways to have the work done without triggering a reported error?
Beta Was this translation helpful? Give feedback.
All reactions