Some questions about using @overload decorator correctly #5168
szw0407
started this conversation in
Enhancement
Replies: 1 comment 2 replies
-
The previous version of this question is fixed when I switch to the pre-release version of Pylance, but perhaps there are still some issues. The new example may be due to usage of the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Below is an example code:
May I give another example code:
I have declared the Type of args when
all_int
is in kwargs.keys() the args must be all integers, but whenall_str
appears, it will be all strings. I can useall(isinstance(args, int))
to check the types but I guess that was not necessary if Pylance could read the overload function declearations. Moreover, even if I did so,all
function is not supported yet.It might be asked why I am using
kwargs
instead of writing all the names of variables in the function body. Well, I think usingkwargs
makes my code more readable and clear.Perhaps I misunderstood what overload could do. And I found #4526 . It had been marked as completed, and I am not sure whether some exceptions still exist. Thanks for your help.
Beta Was this translation helpful? Give feedback.
All reactions