funcsigs
Backport of Python 3's PEP 362 function signature introspection to Python 2.7.
Repository Health
Technical Analysis
funcsigs is a backport of the PEP 362 function-signature features from Python 3’s inspect module, making the modern Signature introspection API available on Python 2.7 (and 3.4+). It lets legacy codebases inspect a callable’s parameters, defaults, annotations, and kinds through the same Signature and Parameter objects that shipped natively in Python 3.3.
Although Python 2 is now end-of-life, funcsigs remains widely downloaded as a transitive dependency of tools like mock that once needed to run on both Python 2 and 3. On Python 3 it simply proxies to the standard library, so it is safe as a compatibility shim.
What You Get
- A signature() function that inspects any callable’s parameters
- Signature and Parameter objects mirroring Python 3’s inspect API
- Access to parameter names, defaults, kinds, and annotations on Python 2.7
- Transparent pass-through to the standard library when running on Python 3
- A drop-in compatibility shim for cross-version (Python 2/3) code
Common Use Cases
- Introspecting callable signatures in code that must still run on Python 2.7
- Providing a uniform signature API across Python 2 and 3 in libraries
- Satisfying transitive dependencies (for example older versions of mock)
- Building decorators or dispatchers that reason about function parameters on legacy interpreters
Under The Hood
Architecture
The entire library lives in a compact funcsigs/ package (__init__.py plus version.py). __init__.py contains the backported Signature, Parameter, BoundArguments, and signature() implementations copied and adapted from CPython’s inspect module, guarding for the Python 2 edge cases the README documents (such as __wrapped__ assignment and builtin __call__ handling).
Tech Stack Pure Python with no runtime dependencies, packaged via classic setuptools (setup.py/setup.cfg) and tested across interpreters with tox. Documentation is built with Sphinx.
Code Quality
The package ships a tests/ suite exercised historically under Travis CI across CPython 2.7, 3.4, 3.5, and nightlies, plus PyPy. Because it mirrors CPython’s own inspect implementation, correctness is anchored to the reference behavior it backports. The project is now inactive, reflecting the end of life of its primary Python 2 use case.
API Design
The API is intentionally identical to inspect.signature, so there is essentially nothing new to learn: import signature from funcsigs instead of inspect and everything else behaves the same. That one-to-one correspondence is the whole point and makes adoption trivial for anyone targeting mixed Python 2/3 support.