Skip to main content

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

Python 3.9+ License: MIT CI PyPI version

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

python_introspect-0.1.0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_introspect-0.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

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

Hashes for python_introspect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2aa9b91ca0536d9c96693cd990903a77ed097cc689c88741df536704a155e864
MD5 f21663ce3e4ddabfe65eb0d122f50879
BLAKE2b-256 a9bf2efc3ecd9c4ae5400fc80a21c40406d9b3d839982f974e7439cda9e68509

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_introspect-0.1.0.tar.gz:

Publisher: publish.yml on OpenHCSDev/python-introspect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_introspect-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_introspect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a0d7b0f06578ca2afd7bf033d2de788e6d6cf73ef0af30a2a176346edfbef51
MD5 c9e7f221a00a84c58cf8e839385c7217
BLAKE2b-256 30302f751f36f529fd2e91fb94657b6cc316735438c1515acac527ae6696d266

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_introspect-0.1.0-py3-none-any.whl:

Publisher: publish.yml on OpenHCSDev/python-introspect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page