Added a decorator function to validate parameters 
State: closed

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.

Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
Hello @shantanuo! Thanks for updating the PR.

 - In the file [`pandas/io/excel.py`](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/io/excel.py), following are the PEP8 issues :

> [Line 282:1](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/io/excel.py#L282): [E302](https://duckduckgo.com/?q=pep8%20E302) expected 2 blank lines, found 1

 - In the file [`pandas/util/_decorators.py`](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py), following are the PEP8 issues :

> [Line 8:1](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L8): [E302](https://duckduckgo.com/?q=pep8%20E302) expected 2 blank lines, found 1
> [Line 12:26](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L12): [E225](https://duckduckgo.com/?q=pep8%20E225) missing whitespace around operator
> [Line 12:50](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L12): [E231](https://duckduckgo.com/?q=pep8%20E231) missing whitespace after ','
> [Line 12:80](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L12): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (122 > 79 characters)
> [Line 12:123](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L12): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace
> [Line 13:16](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L13): [E128](https://duckduckgo.com/?q=pep8%20E128) continuation line under-indented for visual indent
> [Line 13:44](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L13): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 13:80](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L13): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (120 > 79 characters)
> [Line 14:16](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L14): [E128](https://duckduckgo.com/?q=pep8%20E128) continuation line under-indented for visual indent
> [Line 14:80](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L14): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (85 > 79 characters)
> [Line 16:61](https://github.com/pandas-dev/pandas/blob/0a1f005fe39d028943ef1ff83c50ee214bccc608/pandas/util/_decorators.py#L16): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace



##### 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 `read_excel` then I think the decorator is overkill - would be better served directly within the function body. 

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. 

https://github.com/pandas-dev/pandas/issues/22189

This is the only issue that is holding me back from using pandas and therefore I tried to fix it :)
I think we should focus our efforts on removing the need for `**kwargs` from the signature, rather than trying to work around it.
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 :) 
Removing **kwargs seems to be ideal though. Any one of the two (that is practical, easy and quick) approach should be adopted.
@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.