@@ -33,7 +33,8 @@ def _accept_additional_argument(*args, fun: Callable, arg: str, **kwargs):
3333
3434
3535def free_arguments (fun : Union [Callable , partial ]) -> Set [str ]:
36- """Computes the set of free arguments for a function or [partial object][].
36+ """Computes the set of free arguments for a function or
37+ [functools.partial][] object.
3738
3839 All arguments of a function are considered free unless they are set by a
3940 partial. For example, if `f = partial(g, a=1)`, then `a` is not a free
@@ -44,12 +45,15 @@ def free_arguments(fun: Union[Callable, partial]) -> Set[str]:
4445
4546 Returns:
4647 The set of free arguments of `fun`.
48+
49+ !!! tip "New in version 0.7.0"
4750 """
4851 args_set_by_partial : Set [str ] = set ()
4952
5053 def _rec_unroll_partial_function_args (g : Union [Callable , partial ]) -> Callable :
51- """Stores arguments and recursively call itself if `g` is a partial. In
52- the end, returns the initially wrapped function.
54+ """Stores arguments and recursively call itself if `g` is a
55+ [functools.partial][] object. In the end, returns the initially wrapped
56+ function.
5357
5458 This handles the construct `partial(_accept_additional_argument, *args,
5559 **kwargs)` that is used by `maybe_add_argument`.
@@ -94,6 +98,9 @@ def maybe_add_argument(fun: Callable, new_arg: str) -> Callable:
9498
9599 Returns:
96100 A new function accepting one more keyword argument.
101+
102+ !!! tip "Changed in version 0.7.0"
103+ Ability to work with partials.
97104 """
98105 if new_arg in free_arguments (fun ):
99106 return fun
0 commit comments