-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Added a decorator function to validate parameters #22193
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
to be used as a decorator to validate keyword arguments
Hello @shantanuo! Thanks for updating the PR.
Comment last updated on August 04, 2018 at 03:46 Hours UTC |
Take a look at pandas.util._validators.validate_kwargs |
First and foremost this needs tests. If this is only for Is this in reference a particular issue #? If so can you update your post to link to it? |
This is not only related to "read_excel" function. All read_* methods accept *kwargs due to which non-valid parameters are allowed. This is the only issue that is holding me back from using pandas and therefore I tried to fix it :) |
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 still think the wrapper is overcomplicating things. As mentioned before tests are the most critical thing here and ideally should come before any other coding changes
pandas/util/_decorators.py
Outdated
def _validate_kwarg(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
expected_keys=['io', 'sheet_name','header', 'names', 'index_col', 'usecols', 'squeeze', 'dtype', 'engine', |
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.
Just instantiate this as a set
pandas/util/_decorators.py
Outdated
'date_parser', 'thousands', 'comment', 'skipfooter', 'convert_float'] | ||
|
||
if set(kwargs.keys()).difference(set(expected_keys)): | ||
raise ValueError('invalid parameter found') |
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.
Would be nice to be explicit about which parameter isn't working. Also need a test
I think we should focus our efforts on removing the need for |
sure. Decorator was my shortcut to incorporate the functionality that I needed desperately :) |
Am I missing something? Why is the existing validate_kwargs decorator not up to the task? |
I checked the existing validate_kwargs decorator, but could not figure out how to use it :) |
@shantanuo any plans to add a test to this? I doubt this implementation will be merged, but a test could help us figure out how to use the existing decorators for this purpose. |
closing as stale. if you'd like to continue, pls ping. |
read_excel method needs to check if it has received valid parameters only. Use of **kwds allows any parameter that leads to confusion and bugs.