Skip to content
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

STYLE: run pre-commit filters on the repo #27915

Merged
merged 12 commits into from
Aug 30, 2019

Conversation

basnijholt
Copy link
Contributor

@basnijholt basnijholt commented Aug 14, 2019

I noticed that pre-commit is used and ran pre-commit run --all-files which results in massive diffs, mostly because of isort.

I have added the correct noqa and isort:skip flags to the lines which needed it to function correctly with the current .pre-commit-config.yaml, such that the imports are correctly sorted now.

I also added seed-isort-config such that setup.cfg is parsed for pre-commit and fixed the formatting of .pre-commit-config.yaml.

Finally, there is pandas/__init__.py that is touched by pre-commit run --all-files, however, this has less trivial changes and might result in something breaking, so I don't dare to touch it.
It was because the skip entry in [isort] in setup.cfg is somehow ignored when running pre-commit and I can't figure out why (I will open an issue in the isort repo when it's clear that this will be merged). I have also deleted the other ignored files because I fixed the problems there. pandas/core/api.py needs to stay in skip because isort and black make conflicting edits.

@basnijholt basnijholt changed the title run pre-commit filters on the repo STYLE: run pre-commit filters on the repo Aug 14, 2019
@basnijholt basnijholt force-pushed the pre-commit branch 9 times, most recently from 537079a to 65cc38f Compare August 14, 2019 12:04
@pep8speaks
Copy link

pep8speaks commented Aug 14, 2019

Hello @basnijholt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-19 13:43:32 UTC

@basnijholt basnijholt force-pushed the pre-commit branch 3 times, most recently from e2f3e8c to 476870a Compare August 14, 2019 12:18
@TomAugspurger
Copy link
Contributor

seed-isort-config

Can you say a bit more about why this is needed / what it does? I'm not familiar with it.

@jreback
Copy link
Contributor

jreback commented Aug 15, 2019

are you sure that you have merged the latest master. these should not be necessary.

@basnijholt
Copy link
Contributor Author

@jreback, yes I have just rebased on the latest master.

@basnijholt
Copy link
Contributor Author

@TomAugspurger, seed-isort-config statically populates the known_third_party field, such that isort works correctly. Previously hypothesis wasn't correctly sorted, even though it was already listed. seed-isort-config ensures that all third party libs are there, now isort works as expected.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Aug 19, 2019 via email

@basnijholt
Copy link
Contributor Author

@TomAugspurger there seems to be some kind of circular import. I will fix it! 👍

@basnijholt
Copy link
Contributor Author

basnijholt commented Aug 19, 2019

I think I fixed it.

For some reason DataFrame needs to be imported after NamedAgg to avoid a circular import.

This is probably a bug too, I've added a comment for now.

Also, I've done an interactive rebase on top of master and made the commits into logical separate changes.

@TomAugspurger
Copy link
Contributor

Thanks. Looks like a black issue on our CI: https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=16280.

@basnijholt
Copy link
Contributor Author

All passes now 👍

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

I'll merge later today to give others another chance to review.

hooks:
- id: isort
language: python_venv
- repo: https://github.com/asottile/seed-isort-config
Copy link
Member

Choose a reason for hiding this comment

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

Gave the README a quick glance on this but can you explain what this is doing here?

Copy link

Choose a reason for hiding this comment

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

@TomAugspurger TomAugspurger merged commit 75c9783 into pandas-dev:master Aug 30, 2019
@TomAugspurger TomAugspurger added this to the 1.0 milestone Aug 30, 2019
@TomAugspurger
Copy link
Contributor

Thanks @sbalk!

MarcoGorelli pushed a commit to MarcoGorelli/pandas that referenced this pull request Sep 3, 2019
* add isort:skip to "from .pandas_vb_common import setup"

* add isort:skip to noqa: E402 marked lines

* run black

* add noqa: E402 isort:skip where needed

* run pre-commit filters on asv_bench/benchmarks/

* parse the isort config when using pre-commit

* run isort on pandas/core/api.py

* run pre-commit filters and commit trivial import sorting changes

* specify flake8 errors in pandas/io/msgpack/__init__.py

* fix imports for doc/source/conf.py

* fix the [isort] skip entry in setup.cfg

Also I removed the files for which I have fixed the problems.
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
* add isort:skip to "from .pandas_vb_common import setup"

* add isort:skip to noqa: E402 marked lines

* run black

* add noqa: E402 isort:skip where needed

* run pre-commit filters on asv_bench/benchmarks/

* parse the isort config when using pre-commit

* run isort on pandas/core/api.py

* run pre-commit filters and commit trivial import sorting changes

* specify flake8 errors in pandas/io/msgpack/__init__.py

* fix imports for doc/source/conf.py

* fix the [isort] skip entry in setup.cfg

Also I removed the files for which I have fixed the problems.
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
* add isort:skip to "from .pandas_vb_common import setup"

* add isort:skip to noqa: E402 marked lines

* run black

* add noqa: E402 isort:skip where needed

* run pre-commit filters on asv_bench/benchmarks/

* parse the isort config when using pre-commit

* run isort on pandas/core/api.py

* run pre-commit filters and commit trivial import sorting changes

* specify flake8 errors in pandas/io/msgpack/__init__.py

* fix imports for doc/source/conf.py

* fix the [isort] skip entry in setup.cfg

Also I removed the files for which I have fixed the problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants