Guard against double init hooks
This commit is contained in:
parent
93a36c8572
commit
6001640a8a
@ -33,5 +33,7 @@ class init: # noqa: N801,N806 pylint: disable=invalid-name
|
|||||||
def __call__(self, func: typing.Callable) -> typing.Callable:
|
def __call__(self, func: typing.Callable) -> typing.Callable:
|
||||||
module = importlib.import_module(func.__module__)
|
module = importlib.import_module(func.__module__)
|
||||||
info = loader.add_module_info(module)
|
info = loader.add_module_info(module)
|
||||||
|
if info.init_hook is not None:
|
||||||
|
raise ValueError("init hook is already registered!")
|
||||||
info.init_hook = func
|
info.init_hook = func
|
||||||
return func
|
return func
|
||||||
|
Loading…
Reference in New Issue
Block a user