Skip to content

Commit

Permalink
Run pre-commit (with pyupgrade) on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Dec 7, 2024
1 parent d04211d commit b05954e
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 41 deletions.
9 changes: 4 additions & 5 deletions src/pluggy/_callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

from __future__ import annotations

from collections.abc import Generator
from collections.abc import Mapping
from collections.abc import Sequence
from typing import cast
from typing import Generator
from typing import Mapping
from typing import NoReturn
from typing import Sequence
from typing import Tuple
from typing import Union
import warnings

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

Expand Down
16 changes: 7 additions & 9 deletions src/pluggy/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

from __future__ import annotations

from collections.abc import Generator
from collections.abc import Mapping
from collections.abc import Sequence
from collections.abc import Set
import inspect
import sys
from types import ModuleType
from typing import AbstractSet
from typing import Any
from typing import Callable
from typing import Final
from typing import final
from typing import Generator
from typing import List
from typing import Mapping
from typing import Optional
from typing import overload
from typing import Sequence
from typing import Tuple
from typing import TYPE_CHECKING
from typing import TypedDict
from typing import TypeVar
Expand All @@ -34,7 +32,7 @@
_Plugin = object
_HookExec = Callable[
[str, Sequence["HookImpl"], Mapping[str, object], bool],
Union[object, List[object]],
Union[object, list[object]],
]
_HookImplFunction = Callable[..., Union[_T, Generator[None, Result[_T], None]]]

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


_CallHistory = List[Tuple[Mapping[str, object], Optional[Callable[[Any], None]]]]
_CallHistory = list[tuple[Mapping[str, object], Optional[Callable[[Any], None]]]]


class HookCaller:
Expand Down Expand Up @@ -608,7 +606,7 @@ class _SubsetHookCaller(HookCaller):
"_remove_plugins",
)

def __init__(self, orig: HookCaller, remove_plugins: AbstractSet[_Plugin]) -> None:
def __init__(self, orig: HookCaller, remove_plugins: Set[_Plugin]) -> None:
self._orig = orig
self._remove_plugins = remove_plugins
self.name = orig.name # type: ignore[misc]
Expand Down
6 changes: 3 additions & 3 deletions src/pluggy/_manager.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

from collections.abc import Iterable
from collections.abc import Mapping
from collections.abc import Sequence
import inspect
import types
from typing import Any
from typing import Callable
from typing import cast
from typing import Final
from typing import Iterable
from typing import Mapping
from typing import Sequence
from typing import TYPE_CHECKING
import warnings

Expand Down
4 changes: 1 addition & 3 deletions src/pluggy/_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
from typing import final
from typing import Generic
from typing import Optional
from typing import Tuple
from typing import Type
from typing import TypeVar


_ExcInfo = Tuple[Type[BaseException], BaseException, Optional[TracebackType]]
_ExcInfo = tuple[type[BaseException], BaseException, Optional[TracebackType]]
ResultType = TypeVar("ResultType")


Expand Down
5 changes: 2 additions & 3 deletions src/pluggy/_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

from __future__ import annotations

from collections.abc import Sequence
from typing import Any
from typing import Callable
from typing import Sequence
from typing import Tuple


_Writer = Callable[[str], object]
_Processor = Callable[[Tuple[str, ...], Tuple[Any, ...]], object]
_Processor = Callable[[tuple[str, ...], tuple[Any, ...]], object]


class TagTracer:
Expand Down
7 changes: 3 additions & 4 deletions testing/test_hookcaller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from collections.abc import Generator
from collections.abc import Sequence
from typing import Callable
from typing import Generator
from typing import List
from typing import Sequence
from typing import TypeVar

import pytest
Expand Down Expand Up @@ -63,7 +62,7 @@ def addmeth(hc: HookCaller) -> AddMeth:
return AddMeth(hc)


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


Expand Down
2 changes: 1 addition & 1 deletion testing/test_invocations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterator
from collections.abc import Iterator

import pytest

Expand Down
12 changes: 5 additions & 7 deletions testing/test_multicall.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from collections.abc import Mapping
from collections.abc import Sequence
from typing import Callable
from typing import List
from typing import Mapping
from typing import Sequence
from typing import Type
from typing import Union

import pytest
Expand All @@ -22,7 +20,7 @@ def MC(
methods: Sequence[Callable[..., object]],
kwargs: Mapping[str, object],
firstresult: bool = False,
) -> Union[object, List[object]]:
) -> Union[object, list[object]]:
caller = _multicall
hookfuncs = []
for method in methods:
Expand Down Expand Up @@ -250,7 +248,7 @@ def m1():


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

@hookimpl(hookwrapper=True)
Expand Down Expand Up @@ -320,7 +318,7 @@ def m4():


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

@hookimpl(wrapper=True)
Expand Down
5 changes: 2 additions & 3 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import importlib.metadata
from typing import Any
from typing import List

import pytest

Expand Down Expand Up @@ -606,7 +605,7 @@ def my_distributions():


def test_add_tracefuncs(he_pm: PluginManager) -> None:
out: List[Any] = []
out: list[Any] = []

class api1:
@hookimpl
Expand Down Expand Up @@ -659,7 +658,7 @@ def he_method1(self):
raise ValueError()

he_pm.register(api1())
out: List[Any] = []
out: list[Any] = []
he_pm.trace.root.setwriter(out.append)
undo = he_pm.enable_tracing()
try:
Expand Down
4 changes: 1 addition & 3 deletions testing/test_tracer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

import pytest

from pluggy._tracing import TagTracer
Expand All @@ -13,7 +11,7 @@ def rootlogger() -> TagTracer:
def test_simple(rootlogger: TagTracer) -> None:
log = rootlogger.get("pytest")
log("hello")
out: List[str] = []
out: list[str] = []
rootlogger.setwriter(out.append)
log("world")
assert len(out) == 1
Expand Down

0 comments on commit b05954e

Please sign in to comment.