Pure Python introspection toolkit for function signatures, dataclasses, and type hints
Project description
python-introspect
Pure Python introspection toolkit for function signatures, dataclasses, and type hints
Features
- 🔍 Function/Method Signature Analysis - Extract parameter info from any callable
- 📦 Dataclass Field Extraction - Analyze dataclass fields and types
- 📝 Docstring Parsing - Extract and parse docstrings (Google, NumPy, Sphinx styles)
- 🏷️ Type Hint Resolution - Resolve complex type hints and annotations
- 🎯 Unified API - Single interface for all parameter sources
- 🚀 Pure Python - No external dependencies, pure stdlib
Installation
pip install python-introspect
Quick Start
from python_introspect import SignatureAnalyzer
def example_function(name: str, age: int = 25, *, active: bool = True):
"""
Example function with parameters.
Args:
name: The person's name
age: The person's age
active: Whether the person is active
"""
pass
# Analyze the function
analyzer = SignatureAnalyzer()
params = analyzer.analyze_function(example_function)
for param in params:
print(f"{param.name}: {param.annotation} = {param.default}")
Use Cases
- Form Generation - Generate UI forms from function signatures
- API Documentation - Auto-generate API docs from code
- Configuration Validation - Validate config against function parameters
- Dynamic UI - Build dynamic UIs based on function signatures
- Parameter Analysis - Analyze and validate function parameters
Documentation
Full documentation available at: https://github.com/trissim/python-introspect
Development
Setup
# Clone the repository
git clone https://github.com/trissim/python-introspect.git
cd python-introspect
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode with dev dependencies
pip install -e ".[dev]"
Running Tests
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=python_introspect --cov-report=term --cov-report=html
# Run linting and formatting checks
ruff check src/ tests/
black --check src/ tests/
mypy src/python_introspect/
Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
Credits
Developed by Tristan Simas as part of the OpenHCS project.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_introspect-0.1.0.tar.gz.
File metadata
- Download URL: python_introspect-0.1.0.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aa9b91ca0536d9c96693cd990903a77ed097cc689c88741df536704a155e864
|
|
| MD5 |
f21663ce3e4ddabfe65eb0d122f50879
|
|
| BLAKE2b-256 |
a9bf2efc3ecd9c4ae5400fc80a21c40406d9b3d839982f974e7439cda9e68509
|
Provenance
The following attestation bundles were made for python_introspect-0.1.0.tar.gz:
Publisher:
publish.yml on OpenHCSDev/python-introspect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_introspect-0.1.0.tar.gz -
Subject digest:
2aa9b91ca0536d9c96693cd990903a77ed097cc689c88741df536704a155e864 - Sigstore transparency entry: 854596971
- Sigstore integration time:
-
Permalink:
OpenHCSDev/python-introspect@6a457d8c04ad6d97d3ebac05c3f39ad13a25202a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/OpenHCSDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6a457d8c04ad6d97d3ebac05c3f39ad13a25202a -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_introspect-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_introspect-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a0d7b0f06578ca2afd7bf033d2de788e6d6cf73ef0af30a2a176346edfbef51
|
|
| MD5 |
c9e7f221a00a84c58cf8e839385c7217
|
|
| BLAKE2b-256 |
30302f751f36f529fd2e91fb94657b6cc316735438c1515acac527ae6696d266
|
Provenance
The following attestation bundles were made for python_introspect-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on OpenHCSDev/python-introspect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_introspect-0.1.0-py3-none-any.whl -
Subject digest:
2a0d7b0f06578ca2afd7bf033d2de788e6d6cf73ef0af30a2a176346edfbef51 - Sigstore transparency entry: 854596984
- Sigstore integration time:
-
Permalink:
OpenHCSDev/python-introspect@6a457d8c04ad6d97d3ebac05c3f39ad13a25202a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/OpenHCSDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6a457d8c04ad6d97d3ebac05c3f39ad13a25202a -
Trigger Event:
push
-
Statement type: