Skip to content

Fix validation error type PR02 and check in CI #25376

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

Closed
2 tasks
MarckK opened this issue Feb 19, 2019 · 9 comments
Closed
2 tasks

Fix validation error type PR02 and check in CI #25376

MarckK opened this issue Feb 19, 2019 · 9 comments
Labels
CI Continuous Integration Code Style Code style, linting, code_checks Docs

Comments

@MarckK
Copy link
Contributor

MarckK commented Feb 19, 2019

Problem description

In order to have a continuous check by the CI on validation error PR02 (Unknown parameters), fixing them in the code base enables the addition to the CI for automated testing in the future.

Please see overview of the errors.

Todo:

  • get rid of the errors in the code base
  • update the code_check.sh script to take into account the PR02 type of errors
@gfyoung gfyoung added Docs CI Continuous Integration Code Style Code style, linting, code_checks good first issue labels Feb 21, 2019
@nickagian
Copy link

I'll work on that if no objection!

@MarckK
Copy link
Contributor Author

MarckK commented Feb 21, 2019

Yes, please do @nickagian. :)

@nickagian
Copy link

Ok, I'd like some help.

There are many cases that have the same root cause but I don't know how to solve this.

It happens when a method gets delegated from a class to another. Usually by using the pandas.core.accessor.delegate_names decorator.

The problem is that the new class gets a method method_name(self, *args, **kwargs) but the docstring it inherits` has the parameters by their names and this obviously creates validation errors.

Any ideas on how to solve this?

I thought perhaps of passing also the desired docstring to the decorator instead of using the one from the original class, but I am not sure if that is a good idea.

@TomAugspurger
Copy link
Contributor

@nickagian do you have an example of a method that is failing this check?

@TomAugspurger
Copy link
Contributor

Found one, pd.Series.dt.to_period. I think the proper fix is to ensure that the signature of these (generated) methods is correct. This is possible, but not the most straightforward.

@nickagian
Copy link

@TomAugspurger Yes exactly, or pandas.CategoricalIndex.rename_categories and many more.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Feb 27, 2019 via email

@nickagian
Copy link

I have another question, regarding the pandas.core.groupby.base.whitelist_method_generator function. I think there is a bug here when we check if isinstance(f, types.MethodType):.

This is wrong if applied directly to a class, since f is only a function not bound to any object yet. Thus, the check we do here will give False anyways.

This creates a family of PR02 errors, for example for pandas.core.groupby.DataFrameGroupBy.quantile. This is wrongly treated as property due to the bug (it is actually a method) and this results in this validation error.

My question is: Is there a way to do this check correctly?
I haven't found a way so I think one solution would be to add an additional parameter to the pandas.core.groupby.base.whitelist_method_generator function that defines the type (method or property).

The only drawback is we have to provide the method names in the whitelist parameter each time it is called. If you spend one minute in the code you'll notice that right now the approach is that we basically define this list in the pandas.core.groupby.base module (common_apply_whitelist, dataframe_apply_whitelist etc.). An alternative would be to modify these lists into dictionaries, where also the type (property or method) is provided.

@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Dec 11, 2019
@mroeschke
Copy link
Member

Closing as a duplicate of #27976

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Code Style Code style, linting, code_checks Docs
Projects
None yet
Development

No branches or pull requests

7 participants