From 34b26442503f95408eab257df3a362d6b4baf9aa Mon Sep 17 00:00:00 2001 From: valentin-feron Date: Thu, 16 Nov 2023 15:17:00 +0100 Subject: [PATCH] remove depracated Sig method calls --- meshed/base.py | 2 +- meshed/dag.py | 4 ++-- meshed/itools.py | 4 ++-- meshed/slabs.py | 2 +- meshed/tests/test_dag_variadics.py | 4 +--- meshed/util.py | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/meshed/base.py b/meshed/base.py index 170d58ce..c983686e 100644 --- a/meshed/base.py +++ b/meshed/base.py @@ -330,7 +330,7 @@ def call_on_scope(self, scope: MutableMapping, write_output_into_scope=True): an actual interface method. Additional control/constraints on read and writes can be implemented by providing a custom scope for that.""" relevant_kwargs = dict(self.extractor(scope)) - args, kwargs = self.sig.args_and_kwargs_from_kwargs(relevant_kwargs) + args, kwargs = self.sig.mk_args_and_kwargs(relevant_kwargs) output = call_somewhat_forgivingly( self.func, args, kwargs, enforce_sig=self.sig ) diff --git a/meshed/dag.py b/meshed/dag.py index cc6a1eec..c03f9903 100644 --- a/meshed/dag.py +++ b/meshed/dag.py @@ -571,7 +571,7 @@ def _get_kwargs(self, *args, **kwargs): """ Get a dict of {argname: argval} pairs from positional and keyword arguments. """ - return self.__signature__.kwargs_from_args_and_kwargs( + return self.__signature__.map_arguments( args, kwargs, apply_defaults=True ) @@ -831,7 +831,7 @@ def partial( 9 """ - keyword_dflts = self.__signature__.kwargs_from_args_and_kwargs( + keyword_dflts = self.__signature__.map_arguments( args=positional_dflts, kwargs=keyword_dflts, apply_defaults=_consider_defaulted_arguments_as_bound, diff --git a/meshed/itools.py b/meshed/itools.py index 8c8e21f2..d82ed32a 100644 --- a/meshed/itools.py +++ b/meshed/itools.py @@ -51,7 +51,7 @@ def _handle_exclude_nodes(func): @wraps(func) def _func(*args, **kwargs): - kwargs = sig.kwargs_from_args_and_kwargs(args, kwargs, apply_defaults=True) + kwargs = sig.map_arguments(args, kwargs, apply_defaults=True) try: _exclude_nodes = kwargs['_exclude_nodes'] except KeyError: @@ -63,7 +63,7 @@ def _func(*args, **kwargs): _exclude_nodes = set(_exclude_nodes) kwargs['_exclude_nodes'] = _exclude_nodes - args, kwargs = sig.args_and_kwargs_from_kwargs(kwargs) + args, kwargs = sig.mk_args_and_kwargs(kwargs) return func(*args, **kwargs) return _func diff --git a/meshed/slabs.py b/meshed/slabs.py index 83510d2d..85326ab4 100644 --- a/meshed/slabs.py +++ b/meshed/slabs.py @@ -185,7 +185,7 @@ def _call_from_dict(kwargs: MutableMapping, func: Callable, sig: Sig): when there are inputs. """ - args, kwargs = sig.args_and_kwargs_from_kwargs( + args, kwargs = sig.mk_args_and_kwargs( kwargs, allow_excess=True, ignore_kind=True, diff --git a/meshed/tests/test_dag_variadics.py b/meshed/tests/test_dag_variadics.py index 7c0c0635..42582b12 100644 --- a/meshed/tests/test_dag_variadics.py +++ b/meshed/tests/test_dag_variadics.py @@ -3,8 +3,6 @@ from meshed import DAG from i2 import Sig -# from i2.signatures import kwargs_from_args_and_kwargs - @fixture def foo(): @@ -19,7 +17,7 @@ def foo(w, /, x: float, y='YY', *, z: str = 'ZZ', **rest): pass sig = Sig(foo) - # res = sig.kwargs_from_args_and_kwargs( + # res = sig.map_arguments( # (11, 22, "you"), dict(z="zoo", other="stuff"), post_process=True # ) # assert res == "{'w': 11, 'x': 22, 'y': 'you', 'z': 'zoo', 'other': 'stuff'}" diff --git a/meshed/util.py b/meshed/util.py index 9150a5a9..2b32153a 100644 --- a/meshed/util.py +++ b/meshed/util.py @@ -477,7 +477,7 @@ def __init__( self.__signature__ = self._new_sig() def __call__(self, *args, **kwargs): - _kwargs = self.sig.kwargs_from_args_and_kwargs( + _kwargs = self.sig.map_arguments( args, kwargs, apply_defaults=True, allow_partial=True ) first_arg = next(iter(_kwargs.values())) @@ -735,7 +735,7 @@ def named_partial(func, *args, __name__=None, **keywords): def _place_holder_func(*args, _sig=None, **kwargs): - _kwargs = _sig.kwargs_from_args_and_kwargs(args, kwargs) + _kwargs = _sig.map_arguments(args, kwargs) _kwargs_str = ', '.join(f'{k}={v}' for k, v in _kwargs.items()) return f'{_sig.name}({_kwargs_str})'