Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff

ruff is faster and handle everything we had prior.

isort configuration done based on the indication from
https://github.com/astral-sh/ruff/issues/4670, previousely based on
reorder-python-import (#11896)

flake8-docstrings was a wrapper around pydocstyle (now archived) that
explicitly asks to use ruff in https://github.com/PyCQA/pydocstyle/pull/658.

flake8-typing-import is useful mainly for project that support python 3.7
and the one useful check will be implemented in https://github.com/astral-sh/ruff/issues/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>
This commit is contained in:
Pierre Sassoulas
2024-01-31 21:12:33 +01:00
parent 046f64751b
commit 4588653b24
149 changed files with 799 additions and 971 deletions
+7 -9
View File
@@ -2,7 +2,6 @@
from typing import Sequence
from typing import Union
import pytest
from _pytest._code.code import ExceptionChainRepr
from _pytest._code.code import ExceptionRepr
from _pytest.config import Config
@@ -10,6 +9,7 @@ from _pytest.pytester import Pytester
from _pytest.python_api import approx
from _pytest.reports import CollectReport
from _pytest.reports import TestReport
import pytest
class TestReportSerialization:
@@ -279,7 +279,7 @@ class TestReportSerialization:
) -> None:
"""Check serialization/deserialization of report objects containing chained exceptions (#5786)"""
pytester.makepyfile(
"""
f"""
def foo():
raise ValueError('value error')
def test_a():
@@ -287,18 +287,16 @@ class TestReportSerialization:
foo()
except ValueError as e:
raise RuntimeError('runtime error') from e
if {error_during_import}:
if {report_class is CollectReport}:
test_a()
""".format(
error_during_import=report_class is CollectReport
)
"""
)
reprec = pytester.inline_run()
if report_class is TestReport:
reports: Union[Sequence[TestReport], Sequence[CollectReport]] = (
reprec.getreports("pytest_runtest_logreport")
)
reports: Union[
Sequence[TestReport], Sequence[CollectReport]
] = reprec.getreports("pytest_runtest_logreport")
# we have 3 reports: setup/call/teardown
assert len(reports) == 3
# get the call report