summaryrefslogtreecommitdiff
path: root/tests/roots/test-ext-autodoc/target/singledispatch.py
blob: 33dcae43a9f60b64714d50dd96b170a2d5fe6aa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from functools import singledispatch
import inspect


def assign_signature(func):
    # This is intended to cover more complex signature-rewriting decorators.
    func.__signature__ = inspect.signature(func)
    return func


@singledispatch
def func(arg, kwarg=None):
    """A function for general use."""
    pass


@func.register(int)
def _func_int(arg, kwarg=None):
    """A function for int."""
    pass


@func.register(str)
@assign_signature
def _func_str(arg, kwarg=None):
    """A function for str."""
    pass