-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: use correct args and kwargs definitions #256
Conversation
Various methods are defined with improper vardadic positional and keyword-arguments. The original intention for @overload signatures was to provide type support for passthroughs to API query parameter or json arguments. Along the way, *args was introduced to these methods assuming that we wanted to match the dict function signature. In practice, this is confusing since passing SupportsKeysAndGetItem typed variables is rare. Threfore, the *args part of the function signature is removed wherever possible. In the case of update(self, *args, **kwargs) we cannot remove *args since we inherit from dict and dict enforces this method signature.
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
@@ -229,6 +229,7 @@ def restart(self) -> None: | |||
@overload | |||
def update( | |||
self, | |||
*args, |
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.
are these *args additions just for forwards / backwards compatibility?
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.
See below first. This is the equivalent to *, except in this case we have to include *args to match the update signature.
@@ -153,6 +153,7 @@ def find(self, *args, **kwargs) -> List[VisitEvent]: | |||
@overload | |||
def find_one( | |||
self, | |||
*, |
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.
same question about the places we're adding *
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.
This is to say, all arguments after *
must be provided as keyword arguments. So, the user must call find_one(content_guid="asdf")
. find_one("asdf")
will throw an error.
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.
This is what we want since positional argument can change over time.
Various methods are defined with improper variadic positional and keyword arguments. The original intention for
@overload
signatures was to provide type support for pass-throughs to API query parameters or JSON arguments. Along the way, *args was introduced to these methods, assuming we wanted to match the dict function signature. This isn't very clear in practice since passing SupportsKeysAndGetItem typed variables is rare. Therefore, the *args part of the function signature is removed wherever possible. In the update(self, *args, **kwargs), we cannot remove *args since we inherit from dict, and dict enforces this method signature.