From 68300c83667b7036a55f3e85cfde6cd5be707978 Mon Sep 17 00:00:00 2001 From: Vasily Litvinov Date: Fri, 4 Aug 2023 12:50:13 +0300 Subject: [PATCH] Fix getting function arguments --- modin/utils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modin/utils.py b/modin/utils.py index c42163ec0ea..c3b23631928 100644 --- a/modin/utils.py +++ b/modin/utils.py @@ -14,6 +14,7 @@ """Collection of general utility functions, mostly for internal use.""" import importlib +import inspect import os from pathlib import Path import types @@ -461,17 +462,18 @@ def expanduser_path_arg(argname: str) -> Callable[[Fn], Fn]: """ def decorator(func: Callable) -> Callable: + signature = inspect.signature(func) + @functools.wraps(func) - def wrapped(*_args: Any, **_kw: Any) -> Any: - kwargs = dict(locals()) - kwargs.pop("_args", None) - kwargs.pop("_kw", None) - patharg = kwargs[argname] + def wrapped(*args: Any, **kw: Any) -> Any: + params = signature.bind(*args, **kw) + params.apply_defaults() + patharg = params.arguments[argname] if isinstance(patharg, str) and patharg.startswith("~"): - kwargs[argname] = os.path.expanduser(patharg) + params.arguments[argname] = os.path.expanduser(patharg) elif isinstance(patharg, Path): - kwargs[argname] = patharg.expanduser() - return func(**kwargs) + params.arguments[argname] = patharg.expanduser() + return func(**params.arguments) return wrapped