1.13.1 - Fixed regression with generators in python 3.5¶
- Fixed an issue where using
partialon a generator function in python 3.5 was raising a
SyntaxError. Fixed #79
1.13.0 - Support for async generator functions¶
1.12.1 - Bugfix¶
funcattribute is present on the function provided to
create_function. Fixed #76
1.12.0 - Refactoring and consistency improvement¶
partialso that :
- when no argument is provided, it is equivalent to
wraps(f)(f). That is, the
__wrapped__attribute is set. Fixed #73
- it sets the
funcattribute just as
functools.partialdoes. Fixed #75
pytest-casesdependency as it was a circular one. Fixed #68
- Now using
flake8for qualimetry and
genbadgefor badges. Fixed #71
- Restructured project so that tests are truly independent, to ease rpm/apt/etc. packaging. Fixed #69
1.11.3 - bugfix with default values representable but not evaluable¶
- When a default value
vin a signature is representable but its
eval(repr(v))raises an exception, created signatures would raise an exception instead of automatically protecting the symbol. PR #67 by gcalmettes.
1.11.2 - bugfix with chained
- Fixed issue where
@wrapsdoes not remove the
__wrapped__attribute when it wraps an already-wrapped function, and modifies its signature. Fixes #66
1.11.1 - bugfix¶
- Fixed a bug happening when trying to generate a function where
float('inf')is used as a default value. Fixes #63.
partial bugfixes and improvements + new
@wrapsnow has new arguments
append_argto quickly prepend or append a new parameter to a function signature. Fixes #65
add_signature_parameterscan now receive string parameter names in its
Improved generated docstring for
partialwith better support for preset positional args.
partial's behaviour is now aligned with the one in
functools.partialin terms of arguments order and kind. Fixes #64
Bug fix: passing preset positional arguments to
partialdoes not wipe out the rest of the signature any more. Fixes #62
1.10.2 - Github actions test¶
- Technical release: validation of the new github actions workflow.
1.10.1 - Github actions migration¶
- Technical release: validation of the new github actions workflow for PyPi deployment.
1.10.0 - Removing arguments easily in
@wrapsnow offers a
remove_paramsargument allowing one to remove an argument from the exposed signature, typically to create and inject it in the wrapper. Fixes #60
1.9.5 - Bugfix with
partial when f has no args¶
partialcan now be used to create a copy of a function with no args. Fixed
ValueError: Cannot preset 0 positional args, function case_second has only 0 args.. Fixed #59
1.9.4 - removed six dependency¶
- Removed unused
sixdependency. Note: this version will ship in conda forge.
1.9.3 - Minor compatibility fixes with functools.partial¶
@wrapscan now be used to wrap a
functools.partial. Fixed #57
create_functionnow correctly reuses information from the partialized function if a
functools.partialis used as the implementation.
create_functionnow raises a more explicit error when no
func_namecan be found.
makefun.partialnow generates a signature that is more consistent with
functools.partial. Fixes #58
1.9.2 - packaging improvements¶
- packaging improvements: set the "universal wheel" flag to 1, and cleaned up the
setup.py. In particular removed dependency to
sixfor setup and added
py.typedfile, as well as set the
zip_safeflag to False. Removed tests folder from package. Fixes #54
OSError: could not get source code or
IOError: could not get source code when
@compile_fun is used on a function that depends on an already-compiled function. Fixed #51
@compile_fun improvements, bugfix and better exception¶
ValueError: Cell is empty with
@compile_fun. Fixed #48
Now raising an
UndefinedSymbolError when a symbol is not known at compilation time. One step towards #47
1.8.0 - new
@compile_fun decorator to
compile a function so that it can not be navigated to using the debugger. Fixes #46
1.7.0 - minor goodies update¶
add_signature_parameters now accepts that one specifies a custom index where to insert the new parameters.
1.6.11 - Added version attribute¶
1.6.10 - Fixed dependencies 2¶
six dependency: also declared as a setup dependency.
1.6.9 - Fixed dependencies¶
six dependency explicitly.
1.6.8 - Improved performance¶
- Improved performance of inner method
get_signature_string(used by all entry points) after profiling.
1.6.7 - Increased tolerance to function signatures in python 2¶
- In python 2 some libraries such as
attrscan modify the annotations manually, making
signaturereturn a string representation that is not compliant with the language version. This raised a
SyntaxErrorin previous versions. The new version silently removes all these annotations in python versions that do not support them. Fixes #39.
1.6.6 - Bug fix¶
- Fixed yet another nasty varpositional-related bug :). Fixes #38.
1.6.5 - Bug fix¶
NameErrorin case of unknown symbols in type hints. Fixes #37.
1.6.4 - Bug fix and minor improvement¶
1.6.3 - Bug fix with type hints in signature¶
Fixed bug when the return type annotation of the function to create contains non-locally available type hints. Fixes #33.
1.6.2 - Bug fix with type hints in signature¶
Fixed bug when the signature of the function to create contains non-locally available type hints. Fixes #32.
partial minor bug fix¶
partial to support missing and empty docstring. Fixes #31.
1.6.0 - added
partial that behaves like
functools.partial, and equivalent decorator
@with_partial. Fixes #30.
1.5.1 - bug fix¶
add_signature_parameters now correctly inserts parameters in the right order when they are prepended (using
first=). Fixed #29.
1.5.0 - Major refactoring and bugfixes¶
Function creation API:
- renamed all
implfor clarity. Fixes #27.
add_implrespectively, for consistency
- signatures can not be provided as a callable anymore - that was far too confusing. If the reference signature is a callable, then use
create_wrapper, because that's probably what you want to do (= reuse not only the signature but also all metadata). Fixes #26.
- the function name is now optional in signatures provided as string.
- now setting
- default function name, qualname, doc and module name are the ones from
@with_signature, and are the ones from the wrapped function in
@wrapsas intuitively expected. Fixes #28.
create_wrappernow offer a
new_sigargument. In that case the
__wrapped__attribute is not set. Fixes #25.
create_wrappernow correctly preserve the
__dict__and other metadata from the wrapped item. Fixes #24
1.4.0 - Non-representable default values are now handled correctly¶
When a non-representable default value was used in the signature to generate, the code failed with a
SyntaxError. This case is now correctly handled, by storing the corresponding variable in the generated function's context. Fixes #23.
1.3.0 - Aliases for signature-preserving wrapper scenarios¶
Now providing a
@wraps, equivalent of
functools.wraps; and a
functools.update_wrapper. Fixes #21
@with_signaturenow does not override the
__name__when signature is provided as a function. Fixes #22
add_signature_parametersnow accepts that parameters are provided as single elements (not necessarily iterables)
None can be used as the desired signature of
@with_signature. This indicated that the user does not want to create a new function but only wants to update the metadata. Fixes #20.
1.1.2 - Fixes¶
isgeneratorfunction for old python versions, see decorator#63.
Python<3.3-specific function body is now not loaded at all if not needed.
inject_as_first_arg was missing from
@with_signature, added it. Fixed #18.
1.1.0 - Support for generators and coroutines¶
@with_signature create the same kind of function than the handler. So if it is a generator, a generator-based coroutine, or an async coroutine, the generated function will adapt. Fixes #6.
1.0.2 - Fixed
Now a string signature can be provided to
@with_signature without problem. Fixed #17.
1.0.1 - minor: fixed PyPi doc¶
1.0.0 - New parameters, new goodie, and bugfix¶
- now exposes all options of
create_function. Fixed #12.
- now correctly sets the module name by default. Fixes #13
- now accepts
Noneas the new
func_signatureto declare that the signature is identical to the decorated function. This can be handy to just change the docstring or module name of a function for example. Fixes #15
module_nameparameter to override the module name. Fixes #14
- the handler is now available as a field of the generated function (under
addhandlerparameter (default: True) controls this behaviour. Fixes #16
- New goodie to manipulate signatures:
- Fixed dependencies for documentation auto-build.
0.5.0 - New helper function, and bugfix¶
New helper function
Fixed issue with
@with_signature when argument is a
Signature. Fixes #11
0.4.0 - New
@with_signature decorator, and
create_function accepts functions¶
@with_signature to change the signature of a callable. Fixes #3
create_function now accepts that a function be passed as a signature template. Fixes #10
0.3.0 - Ability to generate functions from
Functions can now be created from a
Signature object, in addition to string signatures. This unlocks many useful use cases, among easily creating function wrappers. Note: the inner function that provides this feature is
get_signature_from_string. Fixes #8
Improved design by getting rid of the regular expression parser to check parameters definition. This assumes that the compiler will correctly raise exceptions when a string signature is not correct, and that
funcsigs.signature works correctly at detecting all the parameter kinds and annotations on the resulting function. It seems like a fair assumption... Fixes #9.
0.2.0 - Various new features and improvements¶
create_functiondoes not require users to prepend
"def "to the signature anymore. Fixed #5
Return annotations are now supported. Fixes #4.
Type hint as comments are supported but the generated function loses the annotations because
inspect.signatureloses the annotation too in that case. Fixes #7
Variable-length arguments such as
**kwargsare now properly handled. Fixes #2
Handler functions can now receive the dynamically created function as first argument, by using
create_function(func_signature, func_handler, inject_as_first_arg=True). Fixes #1
_func_impl_in the generated code.
pytest-casesdependency for tests.
0.1.0 - First public version¶
First version created, largely inspired by