{"id":23889,"library":"inspect2","title":"inspect2","description":"Backport of Python 3.6's inspect module to Python 2.7–3.5. Provides the signature() function and other inspection features missing in older Python versions. Current version 0.1.2, low activity.","status":"maintenance","version":"0.1.2","language":"python","source_language":"en","source_url":"https://github.com/JelleZijlstra/inspect2","tags":["inspect","backport","python2","compatibility"],"install":[{"cmd":"pip install inspect2","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Python <3.4 has no inspect.signature; use inspect2 for backport.","wrong":"from inspect import signature","symbol":"signature","correct":"from inspect2 import signature"}],"quickstart":{"code":"from inspect2 import signature\n\ndef foo(a, b=1):\n    return a + b\n\nsig = signature(foo)\nprint(sig.parameters['a'].default is None)\nprint(sig.parameters['b'].default)","lang":"python","description":"Use inspect2.signature to get callable signatures on Python 2.7–3.5."},"warnings":[{"fix":"Use standard library 'inspect' on Python 3.6+.","message":"inspect2 is only needed for Python 2.7–3.5. Python 3.6+ natively includes inspect.signature; using inspect2 on Python 3.6+ may cause import conflicts.","severity":"deprecated","affected_versions":">=3.6"},{"fix":"Use 'from inspect2 import ...' instead of relying on inspect being patched.","message":"inspect2 does not override the built-in inspect module. You must explicitly import from inspect2.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install inspect2 and use 'from inspect2 import signature'.","cause":"Python <3.4 has no inspect.signature, or Python 2.7's inspect does not have signature.","error":"ImportError: cannot import name 'signature' from 'inspect'"},{"fix":"Omit follow_wrapped or upgrade to Python 3.6+ to use inspect.signature.","cause":"inspect2 version 0.1.2 does not support follow_wrapped parameter (Python 3.5+).","error":"TypeError: signature() got an unexpected keyword argument 'follow_wrapped'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}