jbms / sphinx-immaterial

Adaptation of the popular mkdocs-material material design theme to the sphinx documentation system
https://jbms.github.io/sphinx-immaterial/
Other
200 stars 32 forks source link

Issue with `python_transform_type_annotations_pep604` not adding `|` correctly #127

Closed mhostetter closed 2 years ago

mhostetter commented 2 years ago

I'm observing some issues with python_transform_type_annotations_pep604. There are times when Union[a, b] isn't converted to a | b but rather a, b. The same happens when wrapping in an Optional[] type hint.

Here is a reproducible foo project. I'm testing with current main (00c681084ef9ec4be3a936d30367f64802bc7854).

foo-example.zip

def multiplication(x: Union[int, float], y: int) -> float:

image

def func(x: int, y: Optional[Union[int, float]] = None) -> int:

image

mhostetter commented 2 years ago

It also appears python_transform_type_annotations_concise_literal = True doesn't appear to be applied (at least when using python-apigen).

I updated the foo project.

foo-example.zip

def func_2(x: int, option: Literal[1, 2, "abc"]) -> int:

image

jbms commented 2 years ago

I'm not able to reproduce this with Python 3.9, but it may be python version dependent.

jbms commented 2 years ago

Yes, I see that it fails on Python 3.8 --- will have to look into it.

jbms commented 2 years ago

https://github.com/jbms/sphinx-immaterial/runs/7328963050?check_suite_focus=true