Skip to content

Commit 9538f2a

Browse files
committed
Rename HookImplOpts -> HookimplOpts, HookSpecOpts -> HookspecOpts
We already have established types `HookimplMarker`, `HookspecMarker` so we should be consistent with the casing. The types haven't been public in a released version yet so OK to change.
1 parent f6a96ec commit 9538f2a

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/pluggy/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"PluginValidationError",
1111
"HookCaller",
1212
"HookCallError",
13-
"HookSpecOpts",
14-
"HookImplOpts",
13+
"HookspecOpts",
14+
"HookimplOpts",
1515
"HookRelay",
1616
"HookspecMarker",
1717
"HookimplMarker",
@@ -25,6 +25,6 @@
2525
HookimplMarker,
2626
HookCaller,
2727
HookRelay,
28-
HookSpecOpts,
29-
HookImplOpts,
28+
HookspecOpts,
29+
HookimplOpts,
3030
)

src/pluggy/_hooks.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
_HookImplFunction = Callable[..., Union[_T, Generator[None, Result[_T], None]]]
3838

3939

40-
class HookSpecOpts(TypedDict):
40+
class HookspecOpts(TypedDict):
4141
"""Options for a hook specification."""
4242

4343
#: Whether the hook is :ref:`first result only <firstresult>`.
@@ -48,7 +48,7 @@ class HookSpecOpts(TypedDict):
4848
warn_on_impl: Warning | None
4949

5050

51-
class HookImplOpts(TypedDict):
51+
class HookimplOpts(TypedDict):
5252
"""Options for a hook implementation."""
5353

5454
#: Whether the hook implementation is a :ref:`wrapper <hookwrapper>`.
@@ -132,7 +132,7 @@ def __call__( # noqa: F811
132132
def setattr_hookspec_opts(func: _F) -> _F:
133133
if historic and firstresult:
134134
raise ValueError("cannot have a historic firstresult hook")
135-
opts: HookSpecOpts = {
135+
opts: HookspecOpts = {
136136
"firstresult": firstresult,
137137
"historic": historic,
138138
"warn_on_impl": warn_on_impl,
@@ -247,7 +247,7 @@ def __call__( # noqa: F811
247247
"""
248248

249249
def setattr_hookimpl_opts(func: _F) -> _F:
250-
opts: HookImplOpts = {
250+
opts: HookimplOpts = {
251251
"wrapper": wrapper,
252252
"hookwrapper": hookwrapper,
253253
"optionalhook": optionalhook,
@@ -264,7 +264,7 @@ def setattr_hookimpl_opts(func: _F) -> _F:
264264
return setattr_hookimpl_opts(function)
265265

266266

267-
def normalize_hookimpl_opts(opts: HookImplOpts) -> None:
267+
def normalize_hookimpl_opts(opts: HookimplOpts) -> None:
268268
opts.setdefault("tryfirst", False)
269269
opts.setdefault("trylast", False)
270270
opts.setdefault("wrapper", False)
@@ -379,7 +379,7 @@ def __init__(
379379
name: str,
380380
hook_execute: _HookExec,
381381
specmodule_or_class: _Namespace | None = None,
382-
spec_opts: HookSpecOpts | None = None,
382+
spec_opts: HookspecOpts | None = None,
383383
) -> None:
384384
""":meta private:"""
385385
self.name: Final = name
@@ -399,7 +399,7 @@ def has_spec(self) -> bool:
399399
def set_specification(
400400
self,
401401
specmodule_or_class: _Namespace,
402-
spec_opts: HookSpecOpts,
402+
spec_opts: HookspecOpts,
403403
) -> None:
404404
if self.spec is not None:
405405
raise ValueError(
@@ -522,7 +522,7 @@ def call_extra(
522522
not self.is_historic()
523523
), "Cannot directly call a historic hook - use call_historic instead."
524524
self._verify_all_args_are_provided(kwargs)
525-
opts: HookImplOpts = {
525+
opts: HookimplOpts = {
526526
"wrapper": False,
527527
"hookwrapper": False,
528528
"optionalhook": False,
@@ -626,7 +626,7 @@ def __init__(
626626
plugin: _Plugin,
627627
plugin_name: str,
628628
function: _HookImplFunction[object],
629-
hook_impl_opts: HookImplOpts,
629+
hook_impl_opts: HookimplOpts,
630630
) -> None:
631631
self.function: Final = function
632632
self.argnames, self.kwargnames = varnames(self.function)
@@ -654,7 +654,7 @@ class HookSpec:
654654
"warn_on_impl",
655655
)
656656

657-
def __init__(self, namespace: _Namespace, name: str, opts: HookSpecOpts) -> None:
657+
def __init__(self, namespace: _Namespace, name: str, opts: HookspecOpts) -> None:
658658
self.namespace = namespace
659659
self.function: Callable[..., object] = getattr(namespace, name)
660660
self.name = name

src/pluggy/_manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
from ._hooks import _SubsetHookCaller
2121
from ._hooks import HookCaller
2222
from ._hooks import HookImpl
23-
from ._hooks import HookImplOpts
23+
from ._hooks import HookimplOpts
2424
from ._hooks import HookRelay
2525
from ._hooks import HookSpec
26-
from ._hooks import HookSpecOpts
26+
from ._hooks import HookspecOpts
2727
from ._hooks import normalize_hookimpl_opts
2828
from ._result import Result
2929

@@ -166,7 +166,7 @@ def register(self, plugin: _Plugin, name: str | None = None) -> str | None:
166166
hook._add_hookimpl(hookimpl)
167167
return plugin_name
168168

169-
def parse_hookimpl_opts(self, plugin: _Plugin, name: str) -> HookImplOpts | None:
169+
def parse_hookimpl_opts(self, plugin: _Plugin, name: str) -> HookimplOpts | None:
170170
"""Try to obtain a hook implementation from an item with the given name
171171
in the given plugin which is being searched for hook impls.
172172
@@ -181,7 +181,7 @@ def parse_hookimpl_opts(self, plugin: _Plugin, name: str) -> HookImplOpts | None
181181
if not inspect.isroutine(method):
182182
return None
183183
try:
184-
res: HookImplOpts | None = getattr(
184+
res: HookimplOpts | None = getattr(
185185
method, self.project_name + "_impl", None
186186
)
187187
except Exception:
@@ -260,7 +260,7 @@ def add_hookspecs(self, module_or_class: _Namespace) -> None:
260260

261261
def parse_hookspec_opts(
262262
self, module_or_class: _Namespace, name: str
263-
) -> HookSpecOpts | None:
263+
) -> HookspecOpts | None:
264264
"""Try to obtain a hook specification from an item with the given name
265265
in the given module or class which is being searched for hook specs.
266266
@@ -273,7 +273,7 @@ def parse_hookspec_opts(
273273
options for items decorated with :class:`HookspecMarker`.
274274
"""
275275
method: HookSpec = getattr(module_or_class, name)
276-
opts: HookSpecOpts | None = getattr(method, self.project_name + "_spec", None)
276+
opts: HookspecOpts | None = getattr(method, self.project_name + "_spec", None)
277277
return opts
278278

279279
def get_plugins(self) -> set[Any]:

0 commit comments

Comments
 (0)