-
Notifications
You must be signed in to change notification settings - Fork 3
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
Combining |
and xp.ndarray
in a type causes warning in sphinx API docs build
#492
Comments
Similar behaviour involving the
|
Yet another place where similar behaviour is exhibited is anytime Here's a dummy module (called
from typing import TypeAlias, Union
import h5py
MyType: TypeAlias = h5py.Dataset | int
MyOtherType: TypeAlias = Union[h5py.Dataset, int] and in the
but in the |
As part of the warnings seen in #468, with a bit of trial and error I have narrowed down the cause of the "unsupported operand
|
" errors being produced by sphinx, despite running with a python 3.12 interpreter (which should recognise the|
operator as another way to doUnion
).It seems like mixing
|
and types that come from thexp
variable causes the issue. Ifxp
is not used, then the|
poses no problem for sphinx.I found this by being able reproduce the warning sphinx generates, but in a dummy module I created locally in my httomo repo and generating API docs for that module only.
The dummy module (which I lovingly called
bloop.py
) is the following:where you can see that I have defined
xp
as it is defined inutils.py
:httomo/httomo/utils.py
Lines 11 to 21 in f619ed1
Having
Blah
defined as:causes no issues, but having it defined as:
produces the warning:
Furthermore, note that
Thing
uses|
in its definition and that it does not produce the warning in any case.Therefore, I have concluded for now that "something" about using
xp
with|
isn't quite right, but what the "something" is I don't know.I don't fancy trying to dig into sphinx internals or python issues regarding
|
and variables whose values are modules, so I think a reasonable quick solution to this would be to useUnion
if a union type involvingxp
is needed, and to use|
in any other union type.The text was updated successfully, but these errors were encountered: