summaryrefslogtreecommitdiffstats
path: root/tests/roots/test-ext-autodoc/target/singledispatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/roots/test-ext-autodoc/target/singledispatch.py')
-rw-r--r--tests/roots/test-ext-autodoc/target/singledispatch.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/roots/test-ext-autodoc/target/singledispatch.py b/tests/roots/test-ext-autodoc/target/singledispatch.py
new file mode 100644
index 0000000..3dd5aaf
--- /dev/null
+++ b/tests/roots/test-ext-autodoc/target/singledispatch.py
@@ -0,0 +1,36 @@
+import inspect
+from functools import singledispatch
+
+
+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)
+@func.register(float)
+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
+
+
+@func.register
+def _func_dict(arg: dict, kwarg=None):
+ """A function for dict."""
+ # This function tests for specifying type through annotations
+ pass
+