Utilities for working with inspect.Signature objects

4.0.1 · active · verified Thu Apr 09

sigtools is a Python package that enhances introspection capabilities for determining function signatures, especially when decorators modify them. It provides utilities for boosting callable signature introspection, backports keyword-only parameters for older Python versions (though current versions are Python 3+), and tools for combining functions while preserving correct signatures. The current version is 4.0.1, with releases occurring periodically to maintain compatibility and add features.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `sigtools.signature` to introspect a function and how the `@signature` decorator can be used to explicitly set a function's introspectable signature, making `wrapped_func` appear with the same signature as `original_func`.

from sigtools import signature

def original_func(a, b):
    pass

@signature(original_func)
def wrapped_func(c, d):
    # This function's signature is now effectively (a, b) due to @signature(original_func)
    pass

print(f"Original signature: {signature(original_func)}")
print(f"Wrapped signature: {signature(wrapped_func)}")

view raw JSON →