Skip to content

Develop pre check #38663

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

Merged
merged 8 commits into from
Dec 27, 2020
Merged

Conversation

cjlynch278
Copy link
Contributor

@cjlynch278 cjlynch278 commented Dec 23, 2020

- id: check-no-pd-class
name: check for pd class.
types: [python]
entry: pd.testing.assert_series_equal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be pd.testing.* (not exatcly sure how to do the wildcard here). cc @MarcoGorelli

Copy link
Contributor Author

@cjlynch278 cjlynch278 Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see, thanks for the feed back, I'll update this.

@jreback jreback added the Code Style Code style, linting, code_checks label Dec 23, 2020
- id: check-no-pd-class
name: check for pd class.
types: [python]
entry: pd.testing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suspect need to escape \ the dots

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjlynch278 cjlynch278 requested a review from jreback December 23, 2020 22:27
@MarcoGorelli MarcoGorelli self-requested a review December 24, 2020 10:01
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @cjlynch278 !

Could this fit into the existing non-standard-imports-in-tests check? Perhaps it could be renamed to check-unwanted-patterns-in-tests

And yes, you'll need to escape dots (pygrep uses re.search)

@cjlynch278 cjlynch278 marked this pull request as draft December 24, 2020 14:49
@cjlynch278 cjlynch278 marked this pull request as ready for review December 24, 2020 18:38
@cjlynch278
Copy link
Contributor Author

Hey @MarcoGorell and @jreback I added my changes to the existing check, implementing a wildcard. This PR should be ready for final review.

In addition, I think a great approach to implementing the pre-commit library would be to not only identify problems like we do now, but to fix them automatically. We can do this using the search and replace plugin - https://github.com/mattlqx/pre-commit-search-and-replace.

Co-authored-by: Marco Gorelli <[email protected]>
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @cjlynch278 !

@MarcoGorelli MarcoGorelli added this to the 1.3 milestone Dec 27, 2020
@MarcoGorelli MarcoGorelli merged commit edbd479 into pandas-dev:master Dec 27, 2020
@cjlynch278 cjlynch278 deleted the develop-pre-check branch December 28, 2020 03:49
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
* Add the check-no-pd-class hook

* make check more generic

* change instance of pd.testing in test class

* Update .pre-commit-config.yaml

* Add wildcard to entry in pre-commit config file

* Add check to import test check

* Update .pre-commit-config.yaml

Co-authored-by: Marco Gorelli <[email protected]>

Co-authored-by: Marco Gorelli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STYLE: fail on pd.testing direct usage
3 participants