python-makefun
python-makefun copied to clipboard
Dynamically create python functions with a proper signature.
It would return a list of parameters for easy use in the other helper function `add_signature_parameters`
We could introduce two new arguments `first_possible` and `last_possible`, that would intelligently position the provided parameters according to their kind/default value. For example - if there is a `**kwargs`, parameters...
The following fails because the `a` argument ends up in `kwargs` ```python def f(a, *args): pass @wraps(f) def foo(*args, **kwargs): return f(*args, **kwargs) # TypeError: f() got multiple values for...
In many cases when we create function wrappers, we would like to have a single way to write the wrapper rather than handling both generator and regular modes with a...
1.14.0 release introduced this new error in #80 For example `ValueError: Invalid co_name '_results_bag' for created function.` This only happens in python 2.7 and 3.5
```python def f(a): return 2 * a @wraps(f, new_sig="_results_bag()") def g(): return f(2) ``` raises a `KeyError`
```python def funcopy(f): """Creates an actual copy of a function, since python copy() does not""" return partial(f) ```
This fixes #98 My understanding is that here we are trying to say whether a builtin literal for str, int, bytes, or bool would produce the same value as given....
This issue is similar to #63 ```python from enum import StrEnum from makefun import wraps class A(StrEnum): a = 'a' def foo(a=A.a): pass @wraps(foo) def test(*args, **kwargs): return foo(*args, **kwargs)...
There is function ```python def func(a): print(f"Arg: {a}") ``` When it is used by `functiools.partial`: ```python from functools import partial partial(partial(func, a=1), a=2)() """ >>> Arg: 2 """ ``` When...