sigtools
documentation¶
sigtools
is a Python package that improves on introspection tools available
for determining function signatures. This is useful for libraries or tooling
that want to know how a function can be called: Documentation generators, IDEs,
and tools that adapt themselves to functions they are given.
sigtools
provides:
Utilities to boost introspection of callables’ signature
Backports of Python 3’s keyword-only parameters for code that used to maintain both Python 2 and 3 compatibility.
Utilities for combining functions, for instance for creating decorators
A Sphinx extension to make use of improved signature introspection in
sphinx.ext.autodoc
Guide
Reference
- API Reference
sigtools.specifiers
: Decorators to enhance a callable’s signaturesigtools.wrappers
: Combine multiple functionssigtools.signatures
: Signature object manipulationsigtools.modifiers
: Modify the effective signature of the decorated callablesigtools.support
: Utilities for use in interactive sessions and unit testssigtools.sphinxext
: Extension to make Sphinx use signature objects
- Picking the appropriate arguments for
forwards
- Picking the appropriate
forwards_to_*
decorator *args
and**kwargs
are forwarded directly if present- Passing positional arguments to the wrapped function
- Passing named arguments to from the wrapper
- When the outer function uses
*args
or**kwargs
but doesn’t forward them to the inner function - When the outer function passes an arbitrary
*args
or**kwargs
to the inner function - Summary
- Picking the appropriate
Installing¶
You can install sigtools
using pip. If in an activated virtualenv, type:
pip install sigtools
If you wish to do a user-wide install:
pip install --user sigtools