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.2.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.2-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file python_introspect-0.1.2.tar.gz.

File metadata

  • Download URL: python_introspect-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 8440bbc688cb26126c385596b64c0177a758d214b4d14dddf6f622ad78628b5f
MD5 8ffd64cfa702d5bf45b7b15513b288ad
BLAKE2b-256 bc85419eb370cf769bf0672aa845b48ad9e97367d88ea74b65081eab2a44b8b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_introspect-0.1.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python_introspect-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7c6973c0879b9b46ffbe8feb254058e12d399c917e654b3e58f00964e27b55
MD5 ffd125dae3563c4e18b39563e9d55c23
BLAKE2b-256 ddfbc821a25990953156ca7e3e3179b1fd8e9ab21d36683bbad4a96b8a15f9f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_introspect-0.1.2-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