-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Apply isort (forcing single lines, not sorting by type) via ruff #4662
base: master
Are you sure you want to change the base?
Conversation
Looks good to me!
|
Why not apply globally, not to have sort of two standards in the code base?
… |
I think this initial set of files suffices to show the feel of the changes, dropping brackets for multiple entry imports etc. If there are no objections, I would be happy to expand the pull request to apply this to the whole code base - and add this import sorting to the automated checks. |
Expanded to apply import sorting to the entire codebase as suggested, now a monster pull request! |
👹 👍 👍 |
That's weird. The mmtf tests are failing only on MacOS and Windows because the dependency is missing, but going fine on Linux. We should maybe add a try/except to that |
Very odd, it worked locally but I do have
Note https://github.com/biopython/biopython/blob/master/Tests/test_mmtf.py just has try:
from mmtf import fetch, parse
except ImportError:
from Bio import MissingPythonDependencyError
raise MissingPythonDependencyError(
"Install mmtf to use Bio.PDB.mmtf (e.g. pip install mmtf-python)"
) from None So yes, for consistency we can add the try/except to |
I understand the mmtf failure now. After sorting it does: import mmtf # may fail
...
from Bio.PDB.mmtf import MMTFParser, MMTFIO Presorting we did this: from Bio.PDB.mmtf import MMTFParser, MMTFIO # catches failure
...
import mmtf |
That's what it is... thanks for figuring that out! |
I don't expect all the automatically assigned reviewers to review this - but would like more eyes on this before merging. Note this PR would close #2828 by adopting the ruff implementation of an isort style. |
As these are large formatting commits affecting hundreds of files, it might be helpful to skip these commits (along with those in #4655) for ease of viewing in git blame? |
@bzoracler good idea. For similar reasons I used something like black@example.org for the bulk style changes a while back. |
Rebased to deal with the merge conflict in the configuration, and compressed the isort commits into one with a ruff@example.org dummy author. Assuming we merge this, I think a followup PR adding a |
The Python 3.10 failure was #4640 (since fixed). I'll rebase again for the merge conflicts... |
Using ruff v0.3.2 with this command: $ ruff check --fix --select=I \ --config=lint.isort.force-single-line=true \ --config=lint.isort.order-by-type=false \ BioSQL/ Bio/ Tests/ Scripts/ Doc/ setup.py This does also do some blank line changing before/after imports, and I removed a couple of redundant comments about standard library vs local imports.
All the other usage was using from None
Rebased for trivial version updates in the pre-commit config; and some whitespace cleanup spotted while comparing branches. |
Done using ruff v0.3.2 with this command:
This does also do some blank line changing before/after imports, and I removed a couple of redundant comments about standard library vs local imports.
[initially] This focused on modules I look after, but ulitmately I'd like to apply something like this globally. [Update: Done later]
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rst
file, have runpre-commit
locally, and understand that continuous integration checks will be used to
confirm the Biopython unit tests and style checks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rst
andCONTRIB.rst
as part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)
Cross reference #2828