-
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
Support for numpy.typing
#270
Comments
I found this https://stackoverflow.com/a/67483317/11694321. It says to add autodoc_type_aliases = {
"npt.DTypeLike": "~numpy.typing.DTypeLike",
} This now give me the following. It is almost perfect. It is succinct, but the pink |
Do you get any warnings? I would expect this to work. This theme also has its own type alias mechanism that applies to the Python domain generally (not just to autodoc-generated things): https://jbms.github.io/sphinx-immaterial/apidoc/python/index.html#confval-python_type_aliases You could try using that instead. I believe the If you don't specify the autodoc_type_aliases, do you get the same thing except it shows |
I got no warnings. I'm including a reproducible example. foo-270.zip
I'm using Sphinx v5.3.0 and Sphinx Immaterial v0.11.5 in Python 3.8.10. |
This may be another clue... Using the Acceptabledef unpack(x: np.ndarray, bpe: int, dtype: npt.DTypeLike) -> np.ndarray: Something's wrongdef unpack(x: np.ndarray, bpe: int, dtype: npt.DTypeLike = np.uint8) -> np.ndarray: And I now get these warnings.
|
The default value issue is the same as #140. That makes the signature unparsable as an ast, which causes sphinx to fall back to a more heuristic parsing which prevents a lot of things from working. |
I looked into this --- the issue is that There is room for a lot of improvement in that function. Separately, I'd suggest always building with |
I'm running into this again. This function (no def db(
x: npt.ArrayLike,
type: Literal["value", "power", "voltage"] = "value",
) -> npt.NDArray[np.float_]: is rendered like this, which is borderline unreadable. Any thoughts on ways to work around this? I'd really like to use native NumPy types, where possible. Thanks again for all the great work on this theme! |
Hey guys. Hope you're well.
I was adding a type annotation to a function that is
npt.DTypeLike
, see here. However, when displayed withsphinx-immaterial
the underlyingUnion
is unpacked. Is there a way to only displaynpt.DTypeLike
in our API docs?The text was updated successfully, but these errors were encountered: