python-makefun

Dynamically create python functions with a proper signature.

BSD-3-CLAUSE License

Downloads
13.2M
Stars
119
Committers
10

Bot releases are visible (Hide)

python-makefun - 1.1.2 - Fixes

Published by smarie over 5 years ago

Fixed isgeneratorfunction for old python versions, see decorator#63.

Python<3.3-specific function body is now not loaded at all if not needed.

See documentation page for details.

python-makefun - 1.1.1 - `@with_signature` fix

Published by smarie over 5 years ago

inject_as_first_arg was missing from @with_signature, added it. Fixed #18.

See documentation page for details.

python-makefun - 1.1.0 - Support for generators and coroutines

Published by smarie over 5 years ago

Now create_function and @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.

See documentation page for details.

python-makefun - 1.0.2 - Fixed `@with_signature`

Published by smarie over 5 years ago

Now a string signature can be provided to @with_signature without problem. Fixed #17.

See documentation page for details.

python-makefun - 1.0.1 - minor: fixed PyPi doc

Published by smarie over 5 years ago

See documentation page for details.

python-makefun - 1.0.0 - New parameters, new goodie, and bugfix

Published by smarie over 5 years ago

@with_signature :

  • now exposes all options of create_function. Fixed #12.
  • now correctly sets the module name by default. Fixes #13
  • now accepts None as the new func_signature to 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

create_function and @with_signature:

  • New modulename parameter to override the module name. Fixes #14
  • the handler is now available as a field of the generated function (under __call_handler__). New addhandler parameter (default: True) controls this behaviour. Fixes #16

Misc:

  • New goodie to manipulate signatures: add_signature_parameters.
  • Fixed dependencies for documentation auto-build.

See documentation page for details.

python-makefun - 0.5.0 - New helper function, and bugfix

Published by smarie over 5 years ago

New helper function remove_signature_parameters.

Fixed issue with @with_signature when argument is a Signature. Fixes #11

See documentation page for details.

python-makefun - 0.4.0 - New `@with_signature` decorator, and `create_function` accepts functions

Published by smarie over 5 years ago

New decorator @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

See documentation page for details.

python-makefun - 0.3.0 - Ability to generate functions from `Signature`

Published by smarie over 5 years ago

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 inspect.signature or funcsigs.signature works correctly at detecting all the parameter kinds and annotations on the resulting function. It seems like a fair assumption... Fixes #9.

See documentation page for details.

python-makefun - 0.2.0 - Various new features and improvements

Published by smarie over 5 years ago

create_function:

  • create_function does 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.signature loses the annotation too in that case. Fixes #7

  • Variable-length arguments such as *args and **kwargs are 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

  • Renamed _call_ into _call_handler_ in the generated code.

Misc:

  • Added pytest-cases dependency for tests.

See documentation page for details.

Package Rankings
Top 13.26% on Alpine-edge
Top 3.26% on Pypi.org
Top 11.26% on Alpine-v3.18
Top 11.84% on Alpine-v3.15
Top 13.13% on Alpine-v3.16
Top 14.78% on Alpine-v3.17
Top 27.79% on Conda-forge.org
Badges
Extracted from project README
Python versions Build Status Tests Status Coverage Status codecov Flake8 Status Documentation PyPI Downloads Downloads per week GitHub stars