Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 19, 2023
1 parent a3d2066 commit 78431e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/pluggy/_callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Call loop machinery
"""
from __future__ import annotations

from ._hooks import HookImpl
from ._result import _raise_wrapfail
from ._result import HookCallError
from ._result import Result

TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import cast
Expand All @@ -17,7 +19,7 @@

# Need to distinguish between old- and new-style hook wrappers.
# Wrapping one a singleton tuple is the fastest type-safe way I found to do it.
Teardown = Union[
Teardown = Union[
Tuple[Generator[None, Result[object], None]],
Generator[None, object, object],
]
Expand Down
9 changes: 2 additions & 7 deletions src/pluggy/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

from ._result import Result


_T = TypeVar("_T")
_F = TypeVar("_F", bound=Callable[..., object])
_Namespace = Union[ModuleType, type]
Expand All @@ -41,7 +40,6 @@
_HookImplFunction = Callable[..., Union[_T, Generator[None, Result[_T], None]]]
_CallHistory = List[Tuple[Mapping[str, object], Optional[Callable[[Any], None]]]]


class HookspecOpts(TypedDict):
"""Options for a hook specification."""

Expand All @@ -52,7 +50,6 @@ class HookspecOpts(TypedDict):
#: Whether the hook :ref:`warns when implemented <warn_on_impl>`.
warn_on_impl: Warning | None


class HookimplOpts(TypedDict):
"""Options for a hook implementation."""

Expand All @@ -74,11 +71,11 @@ class HookimplOpts(TypedDict):
specname: str | None

else:

def final(func: _F) -> _F:
return func
overload = final


overload = final


@final
Expand Down Expand Up @@ -377,8 +374,6 @@ def __getattr__(self, name: str) -> HookCaller:
_HookRelay = HookRelay




class HookCaller:
"""A caller of all registered implementations of a hook specification."""

Expand Down
6 changes: 4 additions & 2 deletions src/pluggy/_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Hook wrapper "result" utilities.
"""
from __future__ import annotations

TYPE_CHECKING = False
if TYPE_CHECKING:
from types import TracebackType
Expand All @@ -16,16 +17,17 @@
from typing import Type
from typing import TypeVar


_ExcInfo = Tuple[Type[BaseException], BaseException, Optional[TracebackType]]
ResultType = TypeVar("ResultType")
else:
from ._hooks import final

class Generic:
"""fake generic"""
def __class_getitem__(cls, key)-> type[object]:

def __class_getitem__(cls, key) -> type[object]:
return object

ResultType = "ResultType"


Expand Down

0 comments on commit 78431e1

Please sign in to comment.