@@ -58,6 +58,8 @@ class HookspecMarker:
58
58
if the :py:class:`.PluginManager` uses the same project_name.
59
59
"""
60
60
61
+ __slots__ = ("project_name" ,)
62
+
61
63
def __init__ (self , project_name : str ) -> None :
62
64
self .project_name = project_name
63
65
@@ -127,6 +129,8 @@ class HookimplMarker:
127
129
if the :py:class:`.PluginManager` uses the same project_name.
128
130
"""
129
131
132
+ __slots__ = ("project_name" ,)
133
+
130
134
def __init__ (self , project_name : str ) -> None :
131
135
self .project_name = project_name
132
136
@@ -263,9 +267,9 @@ def varnames(func: object) -> Tuple[Tuple[str, ...], Tuple[str, ...]]:
263
267
264
268
class _HookRelay :
265
269
"""hook holder object for performing 1:N hook calls where N is the number
266
- of registered plugins.
270
+ of registered plugins."""
267
271
268
- """
272
+ __slots__ = ( "__dict__" ,)
269
273
270
274
if TYPE_CHECKING :
271
275
@@ -274,6 +278,15 @@ def __getattr__(self, name: str) -> "_HookCaller":
274
278
275
279
276
280
class _HookCaller :
281
+ __slots__ = (
282
+ "name" ,
283
+ "spec" ,
284
+ "_hookexec" ,
285
+ "_wrappers" ,
286
+ "_nonwrappers" ,
287
+ "_call_history" ,
288
+ )
289
+
277
290
def __init__ (
278
291
self ,
279
292
name : str ,
@@ -282,9 +295,9 @@ def __init__(
282
295
spec_opts : Optional ["_HookSpecOpts" ] = None ,
283
296
) -> None :
284
297
self .name = name
298
+ self ._hookexec = hook_execute
285
299
self ._wrappers : List [HookImpl ] = []
286
300
self ._nonwrappers : List [HookImpl ] = []
287
- self ._hookexec = hook_execute
288
301
self ._call_history : Optional [
289
302
List [Tuple [Mapping [str , object ], Optional [Callable [[Any ], None ]]]]
290
303
] = None
@@ -439,6 +452,19 @@ def _maybe_apply_history(self, method: "HookImpl") -> None:
439
452
440
453
441
454
class HookImpl :
455
+ __slots__ = (
456
+ "function" ,
457
+ "argnames" ,
458
+ "kwargnames" ,
459
+ "plugin" ,
460
+ "opts" ,
461
+ "plugin_name" ,
462
+ "hookwrapper" ,
463
+ "optionalhook" ,
464
+ "tryfirst" ,
465
+ "trylast" ,
466
+ )
467
+
442
468
def __init__ (
443
469
self ,
444
470
plugin : _Plugin ,
@@ -461,6 +487,16 @@ def __repr__(self) -> str:
461
487
462
488
463
489
class HookSpec :
490
+ __slots__ = (
491
+ "namespace" ,
492
+ "function" ,
493
+ "name" ,
494
+ "argnames" ,
495
+ "kwargnames" ,
496
+ "opts" ,
497
+ "warn_on_impl" ,
498
+ )
499
+
464
500
def __init__ (self , namespace : _Namespace , name : str , opts : "_HookSpecOpts" ) -> None :
465
501
self .namespace = namespace
466
502
self .function : Callable [..., object ] = getattr (namespace , name )
0 commit comments