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.3.tar.gz (25.4 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.3-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_introspect-0.1.3.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for python_introspect-0.1.3.tar.gz
Algorithm Hash digest
SHA256 28a4db359f089b11fa7ca162fa5ffca3538edd24c98e6027d6ef4cdb480bedae
MD5 3c7d35fcfb175f6d724138aacec1d9c1
BLAKE2b-256 3e009aea11a61ce476fc7e6b4075126418f7b1d472d208bbf1fb592093260dde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_introspect-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6d0f648440f487532ace292c87a8135afecc4c88ba84545830e6c1a1d2dc2e4a
MD5 55e2c93e97187e18a9836b03bff6cdee
BLAKE2b-256 3632b7f8adbdb9ad89108b2652af6f83eaa1a62fe205a81d045974e9548de6c2

See more details on using hashes here.

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