-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Milestone
Description
Describe the bug
When multiple @functools.singledispatch
decorators are stacked (as documented by the stdlib docs at https://docs.python.org/3/library/functools.html#functools.singledispatch), the type annotations reported by sphinx are incorrect.
To Reproduce
Steps to reproduce the behavior:
cat >project.py <<EOF
from functools import singledispatch
@singledispatch
def foo(x): "something"
@foo.register(int)
@foo.register(float)
def _(x): "a number"
EOF
sphinx-apidoc . -o . -F -A me -V 0.0
PYTHONPATH=. make html
then open _build/html/project.html: you get
project.foo(x) [source]
project.foo(x: float)
project.foo(x: float)
something
Expected behavior
The correct overloads are
project.foo(x)
project.foo(x: int)
project.foo(x: float)
Your project
N/A
Screenshots
N/A
Environment info
- OS: Arch Linux
- Python version: 3.9.1
- Sphinx version: 3.4.3
- Sphinx extensions: sphinx.ext.autodoc
- Extra tools: N/A
Additional context
N/A