Skip to content

Commit

Permalink
chore: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Oct 25, 2024
1 parent 020bd55 commit d8f628f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions mknodes/utils/classhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d8f628f

Please sign in to comment.