-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
pre-commit isort #12276
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
pre-commit isort #12276
Conversation
Waiting after the v5.0 branching seems better indeed. Also I think having PRs per subpackage would help for reviews, with less changes to review and the possibility to ask subpackage maintainers to have a look. |
Agreed. I can just spin off portions of this after v5.0 is in.
I think for both of those setup.cfg is "deprecated" in favor of pyproject.toml! |
I don't see where it's deprecated. isort just mentioned some preferred formats (https://pycqa.github.io/isort/docs/configuration/config_files.html), flake8 and pycodestyle don't support |
Also if we add more checks we might want to use https://pre-commit.ci/ which can fix PRs (with a special comment). This would be useful to help contributors instead of asking them to fix things manually. |
I want to emphasize that this should definitely not hold back this PR and if others feel strongly I can revert the
PEP 517 and 518 essentially ensure the slow demise of setup.cfg in favor of a toml file.
You're right. My mistake. Not natively yet. But both acknowledge that's somewhat a problem: PyCQA/pycodestyle#813 Even I just think we might as well start the transition. |
I must agree, that this is a problem, but I sometimes do agree with @asottile that as long as there is no native (built-in) Python support for TOML files, the pyproject.toml might not be helpful, since you may get 5 toml parsers installed with 5 different tools. |
No, they specify a way to use different build systems, with a new config file. Again, setuptools is not deprecated, |
77fffe8
to
8ee74fb
Compare
In my opinion (which may not be relevant here), we are making things too complicated. I'm not opposed to @nstarman running isort locally and opening a bunch or PRs. However, I'm opposed to any sort of magic like pre-commit hooks. For new and also occasional contributors, that's a significant source of confusion. Why does the file look different on GH than locally? Why do I get merge-conflicts when I do X locally and then Y in the GH webinterface and then pull my own branch (not tested, but I bet that can happen)? What does this comment I suggest that the Astropy community decides what is really important. Running CI to make sure tests pass is important. Sorting imports is nice to have, but really just a minor convenience in most cases (almost all files that I've looked at recently have <= 5 imports, so easy to read in any order) and I would argue that having a few files where imports are not sorted "correctly" is a small price to pay to have an easier-to-understand setup for everyone. And, if someone really cares, they can run isort locally and PR the changes, just like it's done here. |
@hamogu. Thanks for the detailed input. I think there may be confusion happening on how
Pre-commit can be installed client-side, by the user, to automatically correct pushes. That's fine because that's their choice and they set it up. So this PR and #11945 do NOT add pre-commit auto-correct. Here It was suggested in #12276 (comment) that the server-side (CI) usage of
I certainly agree that we should make the path to submission as easy as possible. But we already employ
On a more conceptual note, I think adding tools like |
8ee74fb
to
7be27cf
Compare
Before moving too far ahead I wonder if this is something that should be discussed at the next developer telecon unless it has already been discussed? It seems it should be something that should be decided as a group? |
Good suggestion. @adrn can you add this to the agenda for the next dev telecon? |
I see that you have done this in pieces, so I am closing this. Thanks! |
@pllim, this PR does something that the other pieces will not: add isort to the pre-commit CI. |
Then what about conflicts? |
They should disappear as I spin off PRs from this one and rebase. But in this case it's because I ran isort on |
7be27cf
to
aad4786
Compare
@nstarman , if you want to add doc explaining isort, maybe somewhere in |
Just for the record while this PR was closed we do use pre-commit & isort (ruff edition). Everything was done in smaller, more focused PRs. |
Let there be
isort
!Followup to #11945
isort
config topyproject.toml
(preferred location) and modified to auto-skipextern
isort
# isort: skip_file
or# isort: split
so it can be dealt with later668 modified files is a lot to review... so if it helps I pinky promise the above steps were all I did.
Pros:
isort
flag likeskip
orsplit
Cons:
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CI
label.no-changelog-entry-needed
label. If this is a manual backport, use theskip-changelog-checks
label unless special changelog handling is necessary.astropy-bot
check might be missing; do not let the green checkmark fool you.backport-X.Y.x
label(s) before merge.