Skip to content

Commit 06e5923

Browse files
authored
[8.0.x] Replace reorder-python-imports by isort due to black incompatibility (#11898)
Backport of #11896
1 parent a76aa6f commit 06e5923

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+175
-149
lines changed

.gitblameignore renamed to .git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ afc607cfd81458d4e4f3b1f3cf8cc931b933907e
2626

2727
# move argument parser to own file
2828
c9df77cbd6a365dcb73c39618e4842711817e871
29+
30+
# Replace reorder-python-imports by isort due to black incompatibility (#11896)
31+
8b54596639f41dfac070030ef20394b9001fe63c

.pre-commit-config.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 23.12.1
3+
rev: 24.1.1
44
hooks:
55
- id: black
66
args: [--safe, --quiet]
@@ -36,11 +36,12 @@ repos:
3636
additional_dependencies:
3737
- flake8-typing-imports==1.12.0
3838
- flake8-docstrings==1.5.0
39-
- repo: https://github.com/asottile/reorder-python-imports
40-
rev: v3.12.0
39+
- repo: https://github.com/pycqa/isort
40+
rev: 5.13.2
4141
hooks:
42-
- id: reorder-python-imports
43-
args: ['--application-directories=.:src', --py38-plus]
42+
- id: isort
43+
name: isort
44+
args: [--force-single-line, --profile=black]
4445
- repo: https://github.com/asottile/pyupgrade
4546
rev: v3.15.0
4647
hooks:

bench/bench.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
if __name__ == "__main__":
44
import cProfile
5-
import pytest # NOQA
65
import pstats
76

7+
import pytest # NOQA
8+
89
script = sys.argv[1:] if len(sys.argv) > 1 else ["empty.py"]
910
cProfile.run("pytest.cmdline.main(%r)" % script, "prof")
1011
p = pstats.Stats("prof")

doc/en/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,10 @@
441441

442442
def configure_logging(app: "sphinx.application.Sphinx") -> None:
443443
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
444-
import sphinx.util.logging
445444
import logging
446445

446+
import sphinx.util.logging
447+
447448
class WarnLogFilter(logging.Filter):
448449
def filter(self, record: logging.LogRecord) -> bool:
449450
"""Ignore warnings about missing include with "only" directive.

doc/en/example/multipython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Module containing a parametrized tests testing cross-python serialization
22
via the pickle module."""
3+
34
import shutil
45
import subprocess
56
import textwrap
67

78
import pytest
89

9-
1010
pythonlist = ["python3.9", "python3.10", "python3.11"]
1111

1212

scripts/update-plugin-list.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from requests_cache import SQLiteCache
2020
from tqdm import tqdm
2121

22-
2322
FILE_HEAD = r"""
2423
.. Note this file is autogenerated by scripts/update-plugin-list.py - usually weekly via github action
2524

src/_pytest/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
__all__ = ["__version__", "version_tuple"]
22

33
try:
4-
from ._version import version as __version__, version_tuple
4+
from ._version import version as __version__
5+
from ._version import version_tuple
56
except ImportError: # pragma: no cover
67
# broken installation, we don't even try
78
# unknown only works because we do poor mans version compare

src/_pytest/_argcomplete.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
which should throw a KeyError: 'COMPLINE' (which is properly set by the
6262
global argcomplete script).
6363
"""
64+
6465
import argparse
6566
import os
6667
import sys

src/_pytest/_code/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Python inspection/code generation API."""
2+
23
from .code import Code
34
from .code import ExceptionInfo
45
from .code import filter_traceback

src/_pytest/_code/code.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ def ishidden(self, excinfo: Optional["ExceptionInfo[BaseException]"]) -> bool:
277277
278278
Mostly for internal use.
279279
"""
280-
tbh: Union[
281-
bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]
282-
] = False
280+
tbh: Union[bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]] = (
281+
False
282+
)
283283
for maybe_ns_dct in (self.frame.f_locals, self.frame.f_globals):
284284
# in normal cases, f_locals and f_globals are dictionaries
285285
# however via `exec(...)` / `eval(...)` they can be other types
@@ -376,12 +376,10 @@ def cut(
376376
return self
377377

378378
@overload
379-
def __getitem__(self, key: "SupportsIndex") -> TracebackEntry:
380-
...
379+
def __getitem__(self, key: "SupportsIndex") -> TracebackEntry: ...
381380

382381
@overload
383-
def __getitem__(self, key: slice) -> "Traceback":
384-
...
382+
def __getitem__(self, key: slice) -> "Traceback": ...
385383

386384
def __getitem__(
387385
self, key: Union["SupportsIndex", slice]
@@ -1055,13 +1053,13 @@ def repr_excinfo(
10551053
# full support for exception groups added to ExceptionInfo.
10561054
# See https://github.com/pytest-dev/pytest/issues/9159
10571055
if isinstance(e, BaseExceptionGroup):
1058-
reprtraceback: Union[
1059-
ReprTracebackNative, ReprTraceback
1060-
] = ReprTracebackNative(
1061-
traceback.format_exception(
1062-
type(excinfo_.value),
1063-
excinfo_.value,
1064-
excinfo_.traceback[0]._rawentry,
1056+
reprtraceback: Union[ReprTracebackNative, ReprTraceback] = (
1057+
ReprTracebackNative(
1058+
traceback.format_exception(
1059+
type(excinfo_.value),
1060+
excinfo_.value,
1061+
excinfo_.traceback[0]._rawentry,
1062+
)
10651063
)
10661064
)
10671065
else:

0 commit comments

Comments
 (0)