-
-
Notifications
You must be signed in to change notification settings - Fork 316
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
@check_types now properly passes in *args **kwargs and checks their types #1336
Conversation
thanks for the PR! looks like there are some mypy lint errors to address |
c0e632b
to
078c2d6
Compare
Signed-off-by: Ethan Thompson <[email protected]>
Signed-off-by: Ethan Thompson <[email protected]>
Signed-off-by: Ethan Thompson <[email protected]>
Signed-off-by: Ethan Thompson <[email protected]>
Signed-off-by: Ethan Thompson <[email protected]>
Signed-off-by: Ethan Thompson <[email protected]>
7204399
to
6b1396e
Compare
Hi @cosmicBboy, addressed the mypy and black formatting issues in the most recent commit, thanks! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1336 +/- ##
==========================================
+ Coverage 93.91% 94.29% +0.37%
==========================================
Files 91 91
Lines 6775 7024 +249
==========================================
+ Hits 6363 6623 +260
+ Misses 412 401 -11 ☔ View full report in Codecov by Sentry. |
Looks good @ecthompson99 merging now. Congrats on your first PR to pandera! |
Background
sig.bind_partial(*args).arguments
which returns an OrderedDict of arguments or keyword arguments. However:*args
are bundled into a single value:{arg1: 1, args: (2,3,4)}
which is then returned to the wrapped function as(1, (2,3,4))
instead of(1,2,3,4)
**kwargs
are bundled into a nested dictionary:{kwarg1: 1, kwargs: {kwarg2: 2, kwarg3: 3}}
which is then returned to the wrapped function as{kwarg1: 1, {kwargs: {kwarg2: 2, kwarg3: 3}}
instead of{kwarg1: 1, kwarg2: 2, kwarg3: 3}
Implementation
All changes added to
def check_types
(here)validate_args
into two validation functions -- one for positional arguments, one for keyword argumentsdef validate_args
:sig.bind_partial(*args).arguments
) and the nominal arguments. If the lengths match, no *args, and handle normallydef validate_kwargs
:sig.bind_partial(**kwargs).arguments
to the keys in the nominal keyword args. If they are different, then **kwargs existRelated Issue
#1334
Testing
test_check_types_star_args
: Test for *args by comparing argument lengthstest_check_types_star_kwargs
: Test for **kwargs by comparing keystest_check_types_star_args_kwargs
: Test that the values for both *args and **kwargs get passed through correctly