Skip to content
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

autoapi class.rst doesn't render multiple return types #323

Open
2 tasks done
pkrull-ansys opened this issue Nov 17, 2023 · 4 comments
Open
2 tasks done

autoapi class.rst doesn't render multiple return types #323

pkrull-ansys opened this issue Nov 17, 2023 · 4 comments
Assignees
Labels
bug Defects or glitches reported by users or developers

Comments

@pkrull-ansys
Copy link

pkrull-ansys commented Nov 17, 2023

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

    @property
    def geometry(self) -> StlFile | BuildFile:
        """Part geometry."""
        return self._geometry

renders as
image

📝 Steps to reproduce

Write a class property or method that returns multiple possible types and annotate it using 3.10+ annotation style. Generate documentation using autoapi and ansys-sphinx-theme. Only the last return type is shown in the generated docs.

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

24.1

🐍 Which Python version are you using?

3.9

📦 Installed packages

ansys-api-additive==1.4.1
ansys-api-platform-instancemanagement==1.0.0
ansys-platform-instancemanagement==1.1.2
ansys-templates==1.7.0
arrow==1.3.0
binaryornot==0.4.4
bleach==6.1.0
bokeh==3.3.0
cachetools==5.3.2
certifi==2023.7.22
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
contourpy==1.1.1
cookiecutter==2.2.3
coverage==7.3.2
dill==0.3.7
distlib==0.3.7
exceptiongroup==1.1.3
filelock==3.13.1
google-api-core==2.12.0
google-api-python-client==2.106.0
google-auth==2.23.4
google-auth-httplib2==0.1.1
googleapis-common-protos==1.61.0
grpcio==1.59.2
grpcio-health-checking==1.48.2
httplib2==0.22.0
identify==2.5.31
idna==3.4
importlib-metadata==6.8.0
iniconfig==2.0.0
isort==5.12.0
Jinja2==3.1.2
linkify-it-py==2.0.2
Markdown==3.5.1
markdown-it-py==3.0.0
MarkupSafe==2.1.3
mdit-py-plugins==0.4.0
mdurl==0.1.2
nodeenv==1.8.0
numpy==1.26.1
packaging==23.2
pandas==2.1.2
panel==1.3.1
param==2.0.0
Pillow==10.1.0
platformdirs==3.11.0
plotly==5.18.0
pluggy==1.3.0
pre-commit==3.5.0
protobuf==3.20.3
pyasn1==0.5.0
pyasn1-modules==0.3.0
pyparsing==3.1.1
pyproject-api==1.6.1
pytest==7.4.3
pytest-cov==4.1.0
python-dateutil==2.8.2
python-slugify==8.0.1
pytz==2023.3.post1
pyviz_comms==3.0.0
PyYAML==6.0.1
requests==2.31.0
rsa==4.9
six==1.16.0
tenacity==8.2.3
text-unidecode==1.3
tomli==2.0.1
tornado==6.3.3
tox==4.11.3
tqdm==4.66.1
types-python-dateutil==2.8.19.14
typing_extensions==4.8.0
tzdata==2023.3
uc-micro-py==1.0.2
uritemplate==4.1.1
urllib3==2.0.7
virtualenv==20.24.6
webencodings==0.5.1
xyzservices==2023.10.1
zipp==3.17.0
@pkrull-ansys pkrull-ansys added the bug Defects or glitches reported by users or developers label Nov 17, 2023
@RobPasMue
Copy link
Member

This is more of a sphinx-autoapi issue if I am not mistaken. Assigning to @jorgepiloto

@jorgepiloto
Copy link
Member

Thanks for the ping. Roberto is right, we need to check if this comes from our class.rst template or it originates in the internals of sphinx-autoapi.

@jorgepiloto
Copy link
Member

jorgepiloto commented Feb 12, 2024

I thought the | symbol for representing a union was only supported in Python 3.10+. Could you try using:

from typing import Union

  @property
    def geometry(self) -> Union[StlFile, BuildFile]:
        """Part geometry."""
        return self._geometry

This also ensures compatibility with 3.9.

@pkrull-ansys
Copy link
Author

@jorgepiloto The source file contains from __future__ import annotations. I'd prefer to keep the 3.10+ type specifications if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects or glitches reported by users or developers
Projects
None yet
Development

No branches or pull requests

3 participants