Skip to content

Commit 59664be

Browse files
committed
Run pre-commit (with pyupgrade) on all files
1 parent 00ad5fa commit 59664be

10 files changed

+29
-41
lines changed

src/pluggy/_callers.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
from __future__ import annotations
66

7+
from collections.abc import Generator
8+
from collections.abc import Mapping
9+
from collections.abc import Sequence
710
from typing import cast
8-
from typing import Generator
9-
from typing import Mapping
1011
from typing import NoReturn
11-
from typing import Sequence
12-
from typing import Tuple
1312
from typing import Union
1413
import warnings
1514

@@ -22,7 +21,7 @@
2221
# Need to distinguish between old- and new-style hook wrappers.
2322
# Wrapping with a tuple is the fastest type-safe way I found to do it.
2423
Teardown = Union[
25-
Tuple[Generator[None, Result[object], None], HookImpl],
24+
tuple[Generator[None, Result[object], None], HookImpl],
2625
Generator[None, object, object],
2726
]
2827

src/pluggy/_hooks.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@
44

55
from __future__ import annotations
66

7+
from collections.abc import Generator
8+
from collections.abc import Mapping
9+
from collections.abc import Sequence
10+
from collections.abc import Set
711
import inspect
812
import sys
913
from types import ModuleType
10-
from typing import AbstractSet
1114
from typing import Any
1215
from typing import Callable
1316
from typing import Final
1417
from typing import final
15-
from typing import Generator
16-
from typing import List
17-
from typing import Mapping
1818
from typing import Optional
1919
from typing import overload
20-
from typing import Sequence
21-
from typing import Tuple
2220
from typing import TYPE_CHECKING
2321
from typing import TypedDict
2422
from typing import TypeVar
@@ -34,7 +32,7 @@
3432
_Plugin = object
3533
_HookExec = Callable[
3634
[str, Sequence["HookImpl"], Mapping[str, object], bool],
37-
Union[object, List[object]],
35+
Union[object, list[object]],
3836
]
3937
_HookImplFunction = Callable[..., Union[_T, Generator[None, Result[_T], None]]]
4038

@@ -376,7 +374,7 @@ def __getattr__(self, name: str) -> HookCaller: ...
376374
_HookRelay = HookRelay
377375

378376

379-
_CallHistory = List[Tuple[Mapping[str, object], Optional[Callable[[Any], None]]]]
377+
_CallHistory = list[tuple[Mapping[str, object], Optional[Callable[[Any], None]]]]
380378

381379

382380
class HookCaller:
@@ -608,7 +606,7 @@ class _SubsetHookCaller(HookCaller):
608606
"_remove_plugins",
609607
)
610608

611-
def __init__(self, orig: HookCaller, remove_plugins: AbstractSet[_Plugin]) -> None:
609+
def __init__(self, orig: HookCaller, remove_plugins: Set[_Plugin]) -> None:
612610
self._orig = orig
613611
self._remove_plugins = remove_plugins
614612
self.name = orig.name # type: ignore[misc]

src/pluggy/_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from __future__ import annotations
22

3+
from collections.abc import Iterable
4+
from collections.abc import Mapping
5+
from collections.abc import Sequence
36
import inspect
47
import types
58
from typing import Any
69
from typing import Callable
710
from typing import cast
811
from typing import Final
9-
from typing import Iterable
10-
from typing import Mapping
11-
from typing import Sequence
1212
from typing import TYPE_CHECKING
1313
import warnings
1414

src/pluggy/_result.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
from typing import final
1111
from typing import Generic
1212
from typing import Optional
13-
from typing import Tuple
14-
from typing import Type
1513
from typing import TypeVar
1614

1715

18-
_ExcInfo = Tuple[Type[BaseException], BaseException, Optional[TracebackType]]
16+
_ExcInfo = tuple[type[BaseException], BaseException, Optional[TracebackType]]
1917
ResultType = TypeVar("ResultType")
2018

2119

src/pluggy/_tracing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
from __future__ import annotations
66

7+
from collections.abc import Sequence
78
from typing import Any
89
from typing import Callable
9-
from typing import Sequence
10-
from typing import Tuple
1110

1211

1312
_Writer = Callable[[str], object]
14-
_Processor = Callable[[Tuple[str, ...], Tuple[Any, ...]], object]
13+
_Processor = Callable[[tuple[str, ...], tuple[Any, ...]], object]
1514

1615

1716
class TagTracer:

testing/test_hookcaller.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
from collections.abc import Generator
2+
from collections.abc import Sequence
13
from typing import Callable
2-
from typing import Generator
3-
from typing import List
4-
from typing import Sequence
54
from typing import TypeVar
65

76
import pytest
@@ -63,7 +62,7 @@ def addmeth(hc: HookCaller) -> AddMeth:
6362
return AddMeth(hc)
6463

6564

66-
def funcs(hookmethods: Sequence[HookImpl]) -> List[Callable[..., object]]:
65+
def funcs(hookmethods: Sequence[HookImpl]) -> list[Callable[..., object]]:
6766
return [hookmethod.function for hookmethod in hookmethods]
6867

6968

testing/test_invocations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterator
1+
from collections.abc import Iterator
22

33
import pytest
44

testing/test_multicall.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
from collections.abc import Mapping
2+
from collections.abc import Sequence
13
from typing import Callable
2-
from typing import List
3-
from typing import Mapping
4-
from typing import Sequence
5-
from typing import Type
64
from typing import Union
75

86
import pytest
@@ -22,7 +20,7 @@ def MC(
2220
methods: Sequence[Callable[..., object]],
2321
kwargs: Mapping[str, object],
2422
firstresult: bool = False,
25-
) -> Union[object, List[object]]:
23+
) -> Union[object, list[object]]:
2624
caller = _multicall
2725
hookfuncs = []
2826
for method in methods:
@@ -250,7 +248,7 @@ def m1():
250248

251249

252250
@pytest.mark.parametrize("exc", [ValueError, SystemExit])
253-
def test_hookwrapper_exception(exc: "Type[BaseException]") -> None:
251+
def test_hookwrapper_exception(exc: type[BaseException]) -> None:
254252
out = []
255253

256254
@hookimpl(hookwrapper=True)
@@ -320,7 +318,7 @@ def m4():
320318

321319

322320
@pytest.mark.parametrize("exc", [ValueError, SystemExit])
323-
def test_wrapper_exception(exc: "Type[BaseException]") -> None:
321+
def test_wrapper_exception(exc: type[BaseException]) -> None:
324322
out = []
325323

326324
@hookimpl(wrapper=True)

testing/test_pluginmanager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import importlib.metadata
66
from typing import Any
7-
from typing import List
87

98
import pytest
109

@@ -606,7 +605,7 @@ def my_distributions():
606605

607606

608607
def test_add_tracefuncs(he_pm: PluginManager) -> None:
609-
out: List[Any] = []
608+
out: list[Any] = []
610609

611610
class api1:
612611
@hookimpl
@@ -659,7 +658,7 @@ def he_method1(self):
659658
raise ValueError()
660659

661660
he_pm.register(api1())
662-
out: List[Any] = []
661+
out: list[Any] = []
663662
he_pm.trace.root.setwriter(out.append)
664663
undo = he_pm.enable_tracing()
665664
try:

testing/test_tracer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import List
2-
31
import pytest
42

53
from pluggy._tracing import TagTracer
@@ -13,7 +11,7 @@ def rootlogger() -> TagTracer:
1311
def test_simple(rootlogger: TagTracer) -> None:
1412
log = rootlogger.get("pytest")
1513
log("hello")
16-
out: List[str] = []
14+
out: list[str] = []
1715
rootlogger.setwriter(out.append)
1816
log("world")
1917
assert len(out) == 1

0 commit comments

Comments
 (0)