Debian Codegraph @

tests/roots/test-ext-autodoc/target/singledispatch.py

raw
1 import inspect
2 from functools import singledispatch
3
4
5 def assign_signature(func):
6 # This is intended to cover more complex signature-rewriting decorators.
7 func.__signature__ = inspect.signature(func)
8 return func
9
10
11 @singledispatch
12 def func(arg, kwarg=None):
13 """A function for general use."""
14 pass
15
16
17 @func.register(int)
18 @func.register(float)
19 def _func_int(arg, kwarg=None):
20 """A function for int."""
21 pass
22
23
24 @func.register(str)
25 @assign_signature
26 def _func_str(arg, kwarg=None):
27 """A function for str."""
28 pass
29
30
31 @func.register
32 def _func_dict(arg: dict, kwarg=None):
33 """A function for dict."""
34 # This function tests for specifying type through annotations
35 pass