Skip to content

Missing links for a union with an unevaluated type alias #481

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

Open
nineteendo opened this issue Sep 11, 2024 · 1 comment
Open

Missing links for a union with an unevaluated type alias #481

nineteendo opened this issue Sep 11, 2024 · 1 comment

Comments

@nineteendo
Copy link
Contributor

It's not a big deal, but I would like the links to the type definitions to be present on all pages: https://jsonyx.readthedocs.io/en/latest/api/jsonyx.apply_patch.html

# conf.py
autodoc_type_aliases = {"_Operation": "_Operation"}
_Operation = dict[str, Any]

def apply_patch(
    obj: Any,
    patch: _Operation | list[_Operation],
    *,
    allow: Container[str] = NOTHING,
    use_decimal: bool = False,
) -> Any:
    ...
Screenshot 2024-09-11 at 20 23 12
@nineteendo
Copy link
Contributor Author

typing.get_type_hints() raises this error:

TypeError("unsupported operand type(s) for |: 'TypeAliasForwardRef' and 'types.GenericAlias'")

This seems to fix the issue:

-localns = TypeAliasNamespace(app.config["autodoc_type_aliases"])
+localns = {key: ForwardRef(value) for key, value in app.config["autodoc_type_aliases"].items()}

gaborbernat pushed a commit that referenced this issue Apr 25, 2025
Co-authored-by: Wannes Boeykens <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants