Skip to content

Commit 0e34408

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent fdef824 commit 0e34408

6 files changed

Lines changed: 39 additions & 40 deletions

File tree

src/pluggy/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
__all__ = [
2-
"__version__",
3-
"PluginManager",
4-
"PluginValidationError",
5-
"HookCaller",
62
"HookCallError",
7-
"HookspecOpts",
8-
"HookimplOpts",
3+
"HookCaller",
94
"HookImpl",
105
"HookRelay",
11-
"HookspecMarker",
126
"HookimplMarker",
13-
"Result",
14-
"PluggyWarning",
7+
"HookimplOpts",
8+
"HookspecMarker",
9+
"HookspecOpts",
1510
"PluggyTeardownRaisedWarning",
11+
"PluggyWarning",
12+
"PluginManager",
13+
"PluginValidationError",
14+
"Result",
15+
"__version__",
1616
]
1717
from ._hooks import HookCaller
1818
from ._hooks import HookImpl

src/pluggy/_callers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _warn_teardown_exception(
7474
f"A plugin raised an exception during an old-style hookwrapper teardown.\n"
7575
f"Plugin: {hook_impl.plugin_name}, Hook: {hook_name}\n"
7676
f"{type(e).__name__}: {e}\n"
77-
f"For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning" # noqa: E501
77+
f"For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning"
7878
)
7979
warnings.warn(PluggyTeardownRaisedWarning(msg), stacklevel=6)
8080

src/pluggy/_hooks.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def __call__(
9999
warn_on_impl_args: Mapping[str, Warning] | None = None,
100100
) -> _F: ...
101101

102-
@overload # noqa: F811
103-
def __call__( # noqa: F811
102+
@overload
103+
def __call__(
104104
self,
105105
function: None = ...,
106106
firstresult: bool = ...,
@@ -109,7 +109,7 @@ def __call__( # noqa: F811
109109
warn_on_impl_args: Mapping[str, Warning] | None = ...,
110110
) -> Callable[[_F], _F]: ...
111111

112-
def __call__( # noqa: F811
112+
def __call__(
113113
self,
114114
function: _F | None = None,
115115
firstresult: bool = False,
@@ -188,8 +188,8 @@ def __call__(
188188
wrapper: bool = ...,
189189
) -> _F: ...
190190

191-
@overload # noqa: F811
192-
def __call__( # noqa: F811
191+
@overload
192+
def __call__(
193193
self,
194194
function: None = ...,
195195
hookwrapper: bool = ...,
@@ -200,7 +200,7 @@ def __call__( # noqa: F811
200200
wrapper: bool = ...,
201201
) -> Callable[[_F], _F]: ...
202202

203-
def __call__( # noqa: F811
203+
def __call__(
204204
self,
205205
function: _F | None = None,
206206
hookwrapper: bool = False,
@@ -366,9 +366,7 @@ def varnames(
366366
_tail = qualname.rsplit("<locals>.", maxsplit=1)[-1]
367367
_is_class_method = "." in _tail
368368
if args:
369-
if is_bound:
370-
args = args[1:]
371-
elif _is_class_method and args[0] in _IMPLICIT_NAMES:
369+
if is_bound or _is_class_method and args[0] in _IMPLICIT_NAMES:
372370
args = args[1:]
373371
elif _is_class_method and legacy_noself:
374372
if _tail not in _NOSELF_WARN_SUPPRESS:
@@ -412,11 +410,11 @@ class HookCaller:
412410
"""A caller of all registered implementations of a hook specification."""
413411

414412
__slots__ = (
415-
"name",
416-
"spec",
413+
"_call_history",
417414
"_hookexec",
418415
"_hookimpls",
419-
"_call_history",
416+
"name",
417+
"spec",
420418
)
421419

422420
def __init__(
@@ -669,17 +667,17 @@ class HookImpl:
669667
"""A hook implementation in a :class:`HookCaller`."""
670668

671669
__slots__ = (
672-
"function",
673670
"argnames",
671+
"function",
672+
"hookwrapper",
674673
"kwargnames",
675-
"plugin",
674+
"optionalhook",
676675
"opts",
676+
"plugin",
677677
"plugin_name",
678-
"wrapper",
679-
"hookwrapper",
680-
"optionalhook",
681678
"tryfirst",
682679
"trylast",
680+
"wrapper",
683681
)
684682

685683
def __init__(
@@ -725,11 +723,11 @@ def __repr__(self) -> str:
725723
@final
726724
class HookSpec:
727725
__slots__ = (
728-
"namespace",
729-
"function",
730-
"name",
731726
"argnames",
727+
"function",
732728
"kwargnames",
729+
"name",
730+
"namespace",
733731
"opts",
734732
"warn_on_impl",
735733
"warn_on_impl_args",

src/pluggy/_result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Result(Generic[ResultType]):
2626
"""An object used to inspect and set the result in a :ref:`hook wrapper
2727
<hookwrappers>`."""
2828

29-
__slots__ = ("_result", "_exception", "_traceback")
29+
__slots__ = ("_exception", "_result", "_traceback")
3030

3131
def __init__(
3232
self,

testing/test_pluginmanager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,8 @@ def he_method1(self, arg):
441441
with pytest.raises(ZeroDivisionError):
442442
pm.hook.he_method1(arg="works")
443443

444-
with pytest.raises(HookCallError):
445-
with pytest.warns(UserWarning):
446-
pm.hook.he_method1()
444+
with pytest.raises(HookCallError), pytest.warns(UserWarning):
445+
pm.hook.he_method1()
447446

448447

449448
def test_subset_hook_caller(pm: PluginManager) -> None:

testing/test_warnings.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ def my_hook(self):
4040
pm.register(Plugin1(), "plugin1")
4141
pm.register(Plugin2(), "plugin2")
4242
pm.register(Plugin3(), "plugin3")
43-
with pytest.warns(
44-
PluggyTeardownRaisedWarning,
45-
match=r"\bplugin2\b.*\bmy_hook\b.*\n.*ZeroDivisionError",
46-
) as wc:
47-
with pytest.raises(ZeroDivisionError):
48-
pm.hook.my_hook()
43+
with (
44+
pytest.warns(
45+
PluggyTeardownRaisedWarning,
46+
match=r"\bplugin2\b.*\bmy_hook\b.*\n.*ZeroDivisionError",
47+
) as wc,
48+
pytest.raises(ZeroDivisionError),
49+
):
50+
pm.hook.my_hook()
4951
assert len(wc.list) == 1
5052
assert Path(wc.list[0].filename).name == "test_warnings.py"
5153

0 commit comments

Comments
 (0)