24
24
25
25
if TYPE_CHECKING :
26
26
from typing_extensions import TypedDict
27
+ from typing_extensions import Final
27
28
28
29
29
30
_T = TypeVar ("_T" )
@@ -61,7 +62,7 @@ class HookspecMarker:
61
62
__slots__ = ("project_name" ,)
62
63
63
64
def __init__ (self , project_name : str ) -> None :
64
- self .project_name = project_name
65
+ self .project_name : "Final" = project_name
65
66
66
67
@overload
67
68
def __call__ (
@@ -132,7 +133,7 @@ class HookimplMarker:
132
133
__slots__ = ("project_name" ,)
133
134
134
135
def __init__ (self , project_name : str ) -> None :
135
- self .project_name = project_name
136
+ self .project_name : "Final" = project_name
136
137
137
138
@overload
138
139
def __call__ (
@@ -277,6 +278,9 @@ def __getattr__(self, name: str) -> "_HookCaller":
277
278
...
278
279
279
280
281
+ _CallHistory = List [Tuple [Mapping [str , object ], Optional [Callable [[Any ], None ]]]]
282
+
283
+
280
284
class _HookCaller :
281
285
__slots__ = (
282
286
"name" ,
@@ -294,13 +298,11 @@ def __init__(
294
298
specmodule_or_class : Optional [_Namespace ] = None ,
295
299
spec_opts : Optional ["_HookSpecOpts" ] = None ,
296
300
) -> None :
297
- self .name = name
298
- self ._hookexec = hook_execute
299
- self ._wrappers : List [HookImpl ] = []
300
- self ._nonwrappers : List [HookImpl ] = []
301
- self ._call_history : Optional [
302
- List [Tuple [Mapping [str , object ], Optional [Callable [[Any ], None ]]]]
303
- ] = None
301
+ self .name : "Final" = name
302
+ self ._hookexec : "Final" = hook_execute
303
+ self ._wrappers : "Final[List[HookImpl]]" = []
304
+ self ._nonwrappers : "Final[List[HookImpl]]" = []
305
+ self ._call_history : Optional [_CallHistory ] = None
304
306
self .spec : Optional [HookSpec ] = None
305
307
if specmodule_or_class is not None :
306
308
assert spec_opts is not None
@@ -472,7 +474,7 @@ def __init__(
472
474
function : _HookImplFunction [object ],
473
475
hook_impl_opts : "_HookImplOpts" ,
474
476
) -> None :
475
- self .function = function
477
+ self .function : "Final" = function
476
478
self .argnames , self .kwargnames = varnames (self .function )
477
479
self .plugin = plugin
478
480
self .opts = hook_impl_opts
0 commit comments