Skip to content

Commit de161f8

Browse files
authored
Merge pull request #11896 from nicoddemus/isort
Replace reorder-python-imports by isort due to black incompatibility
2 parents e885013 + 3be2a9d commit de161f8

Some content is hidden

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

65 files changed

+142
-147
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
@@ -440,9 +440,10 @@
440440

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

445+
import sphinx.util.logging
446+
446447
class WarnLogFilter(logging.Filter):
447448
def filter(self, record: logging.LogRecord) -> bool:
448449
"""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
@@ -278,9 +278,9 @@ def ishidden(self, excinfo: Optional["ExceptionInfo[BaseException]"]) -> bool:
278278
279279
Mostly for internal use.
280280
"""
281-
tbh: Union[
282-
bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]
283-
] = False
281+
tbh: Union[bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]] = (
282+
False
283+
)
284284
for maybe_ns_dct in (self.frame.f_locals, self.frame.f_globals):
285285
# in normal cases, f_locals and f_globals are dictionaries
286286
# however via `exec(...)` / `eval(...)` they can be other types
@@ -377,12 +377,10 @@ def cut(
377377
return self
378378

379379
@overload
380-
def __getitem__(self, key: "SupportsIndex") -> TracebackEntry:
381-
...
380+
def __getitem__(self, key: "SupportsIndex") -> TracebackEntry: ...
382381

383382
@overload
384-
def __getitem__(self, key: slice) -> "Traceback":
385-
...
383+
def __getitem__(self, key: slice) -> "Traceback": ...
386384

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

0 commit comments

Comments
 (0)