Skip to content

Support for @overloaded callables #80

@CallumJHays

Description

@CallumJHays

This is a bit of a tricky one, but suppose you had something like the following:

@overload
def test(a: int, b: float) -> str: ...
@overload
def test(a: List[int], b: List[float]) -> List[str]: ...
@runtime_validation
def test(a, b):
    return ...

It would be cool if the correct overload could be narrowed down to and validated with the arguments at runtime.

There has been some discussion in the official typing repo on how to accomplish this:
python/typing#711

The gist is to inject a custom @overload implementation. I imagine there'd be work in tricking intellisense servers into thinking it's the original.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions