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

Replace reorder-python-imports by isort due to black incompatibility #11896

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

nicoddemus
Copy link
Member

Unfortunately black and reorder-python-imports are no longer compatible, and from the looks of it probably will not be compatible anytime soon:

asottile/reorder-python-imports#367
asottile/reorder-python-imports#366
psf/black#4175

This replaces reorder-python-imports by isort configured in a way to yield roughtly the same results.

Closes #11885

Unfortunately black and reorder-python-imports are no longer compatible, and from the looks of it probably will not be compatible anytime soon:

asottile/reorder-python-imports#367
asottile/reorder-python-imports#366
psf/black#4175

This replaces `reorder-python-imports` by `isort` configured in a way to yield roughtly the same results.

Closes pytest-dev#11885
Running pre-commit on all files after replacing reorder-python-imports by isort.
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

LGTM. ruff is a drop in replacement for isort, but also for autoflake, flake8, flake8-typing-imports, (flake8-docstrings I don't think so, but I don't know what's inside, maybe it's done by other checks), and pyupgrade, maybe something to consider instead ? It's a single tool, but it's also faster. I can do it and provide a configuration if you want.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

(Approving in case ruff is not desirable)

@nicoddemus
Copy link
Member Author

I'm also leaning towards trying out ruff, but would like to know what others think first.

@nicoddemus
Copy link
Member Author

I'm merging this for now regardless, given otherwise our auto-updates are stuck.

But @Pierre-Sassoulas feel free to open a PR replacing other commit hooks with ruff. 👍

Seems like `.git-blame-ignore-revs` is the standard used and also automatically detected by GitHub:

https://github.blog/changelog/2022-03-24-ignore-commits-in-the-blame-view-beta/
@nicoddemus nicoddemus enabled auto-merge January 31, 2024 10:51
@nicoddemus nicoddemus merged commit de161f8 into pytest-dev:main Jan 31, 2024
23 checks passed
@nicoddemus nicoddemus deleted the isort branch January 31, 2024 11:43
@nicoddemus
Copy link
Member Author

Backporting this to avoid conflicts when backporting future PRs.

nicoddemus added a commit to nicoddemus/pytest that referenced this pull request Jan 31, 2024
nicoddemus added a commit that referenced this pull request Jan 31, 2024
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pytest that referenced this pull request Feb 2, 2024
…e, to ruff

ruff is faster and handle everything we had prior.

isort configuration done based on the indication from
astral-sh/ruff#4670, previousely based on
reorder-python-import (pytest-dev#11896)

flake8-docstrings was a wrapper around pydocstyle (now archived) that
explicitly asks to use ruff in PyCQA/pydocstyle#658.

flake8-typing-import is useful mainly for project that support python 3.7
and the one useful check will be implemented in astral-sh/ruff#2302

We need to keep blacken-doc because ruff does not handle detection
of python code inside .md and .rst. The direct link to the repo is
now used to avoid a redirection.

Manual fixes:
- Lines that became too long
- % formatting that was not done automatically
- type: ignore that were moved around
- noqa of hard to fix issues (UP031 generally)
- fmt: off and fmt: on that is not really identical
  between black and ruff
- autofix re-order in pre-commit from faster to slower

Co-authored-by: Ran Benita <ran@unusedvar.com>
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pytest that referenced this pull request Feb 2, 2024
…e, to ruff

ruff is faster and handle everything we had prior.

isort configuration done based on the indication from
astral-sh/ruff#4670, previousely based on
reorder-python-import (pytest-dev#11896)

flake8-docstrings was a wrapper around pydocstyle (now archived) that
explicitly asks to use ruff in PyCQA/pydocstyle#658.

flake8-typing-import is useful mainly for project that support python 3.7
and the one useful check will be implemented in astral-sh/ruff#2302

We need to keep blacken-doc because ruff does not handle detection
of python code inside .md and .rst. The direct link to the repo is
now used to avoid a redirection.

Manual fixes:
- Lines that became too long
- % formatting that was not done automatically
- type: ignore that were moved around
- noqa of hard to fix issues (UP031 generally)
- fmt: off and fmt: on that is not really identical
  between black and ruff
- autofix re-order in pre-commit from faster to slower

Co-authored-by: Ran Benita <ran@unusedvar.com>
Pierre-Sassoulas added a commit that referenced this pull request Feb 2, 2024
…e, to ruff (#11911)

ruff is faster and handle everything we had prior.

isort configuration done based on the indication from
astral-sh/ruff#4670, previousely based on
reorder-python-import (#11896)

flake8-docstrings was a wrapper around pydocstyle (now archived) that
explicitly asks to use ruff in PyCQA/pydocstyle#658.

flake8-typing-import is useful mainly for project that support python 3.7
and the one useful check will be implemented in astral-sh/ruff#2302

We need to keep blacken-doc because ruff does not handle detection
of python code inside .md and .rst. The direct link to the repo is
now used to avoid a redirection.

Manual fixes:
- Lines that became too long
- % formatting that was not done automatically
- type: ignore that were moved around
- noqa of hard to fix issues (UP031 generally)
- fmt: off and fmt: on that is not really identical
  between black and ruff
- autofix re-order in pre-commit from faster to slower

Co-authored-by: Ran Benita <ran@unusedvar.com>
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.

2 participants