Skip to content

FelixTheC/py-overload

Repository files navigation

strongtyping-pyoverload

Python 3.13 Python 3.14 Python application Python tox image Ruff AI Agents

Runtime method overloading for Python

strongtyping-pyoverload provides a powerful overload decorator that brings true runtime method overloading to Python, similar to C++.

Key Features

  • Native Pydantic Integration: Automatically validate and dispatch based on Pydantic models.
  • Deep Inheritance & Mixin Support: Respects Method Resolution Order (MRO) for complex class hierarchies.
  • AI-Ready Metadata: Sets __signature__ and __annotations__ for better IDE and AI assistant support.
  • High Performance: Optimized lookup logic with caching for minimal overhead.
  • Modern Python: Full support for typing.Annotated, keyword-only parameters, and Python 3.13+.

Quick Start

from strongtyping_pyoverload import overload

class DataProcessor:
    @overload
    def process(self, data: str):
        return data.upper()

    @overload
    def process(self, data: list):
        return [item * 2 for item in data]

Documentation

Full documentation can be found at readthedocs.

About

Real, runtime, multi-argument function overloading in Python

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors