@@ -48,6 +48,11 @@ class HookspecOpts(TypedDict):
4848 historic : bool
4949 #: Whether the hook :ref:`warns when implemented <warn_on_impl>`.
5050 warn_on_impl : Warning | None
51+ #: Whether the hook warns when :ref:`certain arguments are requested
52+ #: <warn_on_impl>`.
53+ #:
54+ #: .. versionadded:: 1.5
55+ warn_on_impl_args : Mapping [str , Warning ] | None
5156
5257
5358class HookimplOpts (TypedDict ):
@@ -92,6 +97,7 @@ def __call__(
9297 firstresult : bool = False ,
9398 historic : bool = False ,
9499 warn_on_impl : Warning | None = None ,
100+ warn_on_impl_args : Mapping [str , Warning ] | None = None ,
95101 ) -> _F : ...
96102
97103 @overload # noqa: F811
@@ -101,6 +107,7 @@ def __call__( # noqa: F811
101107 firstresult : bool = ...,
102108 historic : bool = ...,
103109 warn_on_impl : Warning | None = ...,
110+ warn_on_impl_args : Mapping [str , Warning ] | None = ...,
104111 ) -> Callable [[_F ], _F ]: ...
105112
106113 def __call__ ( # noqa: F811
@@ -109,6 +116,7 @@ def __call__( # noqa: F811
109116 firstresult : bool = False ,
110117 historic : bool = False ,
111118 warn_on_impl : Warning | None = None ,
119+ warn_on_impl_args : Mapping [str , Warning ] | None = None ,
112120 ) -> _F | Callable [[_F ], _F ]:
113121 """If passed a function, directly sets attributes on the function
114122 which will make it discoverable to :meth:`PluginManager.add_hookspecs`.
@@ -128,6 +136,13 @@ def __call__( # noqa: F811
128136 :param warn_on_impl:
129137 If given, every implementation of this hook will trigger the given
130138 warning. See :ref:`warn_on_impl`.
139+
140+ :param warn_on_impl_args:
141+ If given, every implementation of this hook which requests one of
142+ the arguments in the dict will trigger the corresponding warning.
143+ See :ref:`warn_on_impl`.
144+
145+ .. versionadded:: 1.5
131146 """
132147
133148 def setattr_hookspec_opts (func : _F ) -> _F :
@@ -137,6 +152,7 @@ def setattr_hookspec_opts(func: _F) -> _F:
137152 "firstresult" : firstresult ,
138153 "historic" : historic ,
139154 "warn_on_impl" : warn_on_impl ,
155+ "warn_on_impl_args" : warn_on_impl_args ,
140156 }
141157 setattr (func , self .project_name + "_spec" , opts )
142158 return func
@@ -686,6 +702,7 @@ class HookSpec:
686702 "kwargnames" ,
687703 "opts" ,
688704 "warn_on_impl" ,
705+ "warn_on_impl_args" ,
689706 )
690707
691708 def __init__ (self , namespace : _Namespace , name : str , opts : HookspecOpts ) -> None :
@@ -695,3 +712,4 @@ def __init__(self, namespace: _Namespace, name: str, opts: HookspecOpts) -> None
695712 self .argnames , self .kwargnames = varnames (self .function )
696713 self .opts = opts
697714 self .warn_on_impl = opts .get ("warn_on_impl" )
715+ self .warn_on_impl_args = opts .get ("warn_on_impl_args" )
0 commit comments