From d8f628f7a2567093d30fc7c7730b3a8877c0f79b Mon Sep 17 00:00:00 2001 From: Philipp Temminghoff Date: Fri, 25 Oct 2024 03:07:44 +0200 Subject: [PATCH] chore: typing --- mknodes/utils/classhelpers.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mknodes/utils/classhelpers.py b/mknodes/utils/classhelpers.py index d4644e80..3c178da9 100644 --- a/mknodes/utils/classhelpers.py +++ b/mknodes/utils/classhelpers.py @@ -303,16 +303,12 @@ def import_file(path: str | os.PathLike[str]) -> types.ModuleType: raise RuntimeError module = importlib.util.module_from_spec(spec) sys.modules[module_name] = module + assert spec.loader spec.loader.exec_module(module) # type: ignore[union-attr] return module -P = typing.ParamSpec("P") # For parameters -R = typing.TypeVar("R") # For return type - - -@functools.cache -def to_callable(path: str | Callable[P, R]) -> Callable[P, R]: +def to_callable(path: str | Callable[..., Any]) -> Callable[..., Any]: """Return a callable from a string describing the path to a Callable. If path already is a callable, return it without changes.