-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@overload
expands common type unions
#301
Comments
The warnings should be satisfied when intersphinx is given URLs that define the references. Although the references named look like they're supposed to be private, so maybe they aren't included in public docs (& corresponding intersphinx inventories). |
Me neither. Does this same behavior happen when using alabaster theme with autodoc? |
I think you need to use the future annotations feature to retain type aliases. |
I did have |
I still run into this issue, any thoughts? I find myself changing the APIs and functionality of functions to avoid these unreadable call signatures. I appreciate the help! 🙏 Reproducer file: from __future__ import annotations
from typing import Any, overload
import numpy.typing as npt
@overload
def function(x: npt.ArrayLike, return_int: bool = True) -> int: ...
@overload
def function(x: npt.ArrayLike, return_int: bool = False) -> float: ...
def function(x: Any, return_int: Any = False) -> Any:
"""
Group:
dsp-fir-filtering
"""
if return_int:
return 42
else:
return 42.0 Relevant config: nitpicky = True
nitpick_ignore = [
("py:class", "numpy.typing.ArrayLike"), # Wish this would work
("py:class", "numpy.typing.DTypeLike"), # Wish this would work
("py:class", "numpy.typing.NDArray"), # Wish this would work
]
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"scipy": ("http://docs.scipy.org/doc/scipy/reference/", None),
"matplotlib": ("http://matplotlib.sourceforge.net/", None),
"galois": ("https://mhostetter.github.io/galois/latest/", None),
}
autodoc_type_aliases = {
"npt.ArrayLike": "~numpy.typing.ArrayLike",
"npt.DTypeLike": "~numpy.typing.DTypeLike",
"npt.NDArray": "~numpy.typing.NDArray",
}
python_type_aliases = autodoc_type_aliases Relevant warnings:
Output: |
I have noticed that when using overloads, type unions like
npt.ArrayLike
are expanded and become illegible. Not sure if this is a Sphinx or Sphinx Immaterial issue.Here is a brief reproducer. Let me know if you need a full self-contained example.
Renders as this:
With these relevant warnings:
The text was updated successfully, but these errors were encountered: