@@ -70,7 +70,7 @@ def project_name(self) -> str:
70
70
name : str = self .metadata ["name" ]
71
71
return name
72
72
73
- def __getattr__ (self , attr : str , default = None ):
73
+ def __getattr__ (self , attr : str , default : Any | None = None ) -> Any :
74
74
return getattr (self ._dist , attr , default )
75
75
76
76
def __dir__ (self ) -> list [str ]:
@@ -138,14 +138,14 @@ def register(self, plugin: _Plugin, name: str | None = None) -> str | None:
138
138
if self ._name2plugin .get (plugin_name , - 1 ) is None :
139
139
return None # blocked plugin, return None to indicate no registration
140
140
raise ValueError (
141
- "Plugin name already registered: %s=%s \n %s "
142
- % ( plugin_name , plugin , self ._name2plugin )
141
+ "Plugin name already registered: "
142
+ f" { plugin_name } = { plugin } \n { self ._name2plugin } "
143
143
)
144
144
145
145
if plugin in self ._name2plugin .values ():
146
146
raise ValueError (
147
- "Plugin already registered under a different name: %s=%s \n %s "
148
- % ( plugin_name , plugin , self ._name2plugin )
147
+ "Plugin already registered under a different name: "
148
+ f" { plugin_name } = { plugin } \n { self ._name2plugin } "
149
149
)
150
150
151
151
# XXX if an error happens we should make sure no state has been
@@ -329,8 +329,8 @@ def _verify_hook(self, hook: HookCaller, hookimpl: HookImpl) -> None:
329
329
if hook .is_historic () and (hookimpl .hookwrapper or hookimpl .wrapper ):
330
330
raise PluginValidationError (
331
331
hookimpl .plugin ,
332
- "Plugin %r \n hook %r \n historic incompatible with yield/wrapper/hookwrapper "
333
- % ( hookimpl . plugin_name , hook . name ) ,
332
+ f "Plugin { hookimpl . plugin_name !r } \n hook { hook . name !r } \n "
333
+ "historic incompatible with yield/wrapper/hookwrapper" ,
334
334
)
335
335
336
336
assert hook .spec is not None
@@ -342,15 +342,10 @@ def _verify_hook(self, hook: HookCaller, hookimpl: HookImpl) -> None:
342
342
if notinspec :
343
343
raise PluginValidationError (
344
344
hookimpl .plugin ,
345
- "Plugin %r for hook %r\n hookimpl definition: %s\n "
346
- "Argument(s) %s are declared in the hookimpl but "
347
- "can not be found in the hookspec"
348
- % (
349
- hookimpl .plugin_name ,
350
- hook .name ,
351
- _formatdef (hookimpl .function ),
352
- notinspec ,
353
- ),
345
+ f"Plugin { hookimpl .plugin_name !r} for hook { hook .name !r} \n "
346
+ f"hookimpl definition: { _formatdef (hookimpl .function )} \n "
347
+ f"Argument(s) { notinspec } are declared in the hookimpl but "
348
+ "can not be found in the hookspec" ,
354
349
)
355
350
356
351
if hook .spec .warn_on_impl_args :
@@ -364,18 +359,18 @@ def _verify_hook(self, hook: HookCaller, hookimpl: HookImpl) -> None:
364
359
) and not inspect .isgeneratorfunction (hookimpl .function ):
365
360
raise PluginValidationError (
366
361
hookimpl .plugin ,
367
- "Plugin %r for hook %r\n hookimpl definition: %s\n "
362
+ f"Plugin { hookimpl .plugin_name !r} for hook { hook .name !r} \n "
363
+ f"hookimpl definition: { _formatdef (hookimpl .function )} \n "
368
364
"Declared as wrapper=True or hookwrapper=True "
369
- "but function is not a generator function"
370
- % (hookimpl .plugin_name , hook .name , _formatdef (hookimpl .function )),
365
+ "but function is not a generator function" ,
371
366
)
372
367
373
368
if hookimpl .wrapper and hookimpl .hookwrapper :
374
369
raise PluginValidationError (
375
370
hookimpl .plugin ,
376
- "Plugin %r for hook %r \n hookimpl definition: %s \n "
377
- "The wrapper=True and hookwrapper=True options are mutually exclusive "
378
- % ( hookimpl . plugin_name , hook . name , _formatdef ( hookimpl . function )) ,
371
+ f "Plugin { hookimpl . plugin_name !r } for hook { hook . name !r } \n "
372
+ f"hookimpl definition: { _formatdef ( hookimpl . function ) } \n "
373
+ "The wrapper=True and hookwrapper=True options are mutually exclusive" ,
379
374
)
380
375
381
376
def check_pending (self ) -> None :
@@ -390,8 +385,7 @@ def check_pending(self) -> None:
390
385
if not hookimpl .optionalhook :
391
386
raise PluginValidationError (
392
387
hookimpl .plugin ,
393
- "unknown hook %r in plugin %r"
394
- % (name , hookimpl .plugin ),
388
+ f"unknown hook { name !r} in plugin { hookimpl .plugin !r} " ,
395
389
)
396
390
397
391
def load_setuptools_entrypoints (self , group : str , name : str | None = None ) -> int :
0 commit comments