-
Notifications
You must be signed in to change notification settings - Fork 170
Implement Overload decorator in pure python #166
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
Conversation
Smit-create
commented
Feb 24, 2022
- References: Figure out how to handle generic functions #141, Figure out how to handle generic functions #141 (comment)
# This might fail for the cases when arguments don't match | ||
ann_dict = getcallargs(func, *args, **kwargs) | ||
except TypeError: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the arguments don't match, shouldn't we rather raise an exception that the arguments don't match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose, the list contains two functions foo(a)
and foo(a, b)
, then, foo(1, 2)
will raise an error if we use getcallargs
on the first function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. We should determine which of the overloads contains two integer arguments in this case. And just call that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this looks good and we can merge it. I left a comment above about what happens if the arguments don't match, but I think it can be fixed later.