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
typing.Literal["some", "string"] types are represented incorrectly in autodocs #9195
Comments
…y rendered They should be rendered as "repr" form.
I'm having the same issue. Looks like this is because Even if the The following test case would be helpful: from typing import Literal
def func(arg: Literal['\n', '\r\n', '\r']) -> Literal['\n', '\r\n', '\r']:
"""My function.
Args:
arg: my arg
Returns:
my return value
"""
return arg
#: This is a global variable.
global_var: Literal['\n', '\r\n', '\r'] = '\n'
class Context:
"""My context class."""
#: This is a class variable defined in class body.
line_ending: Literal['\n', '\r\n', '\r']
def __init__(self) -> None:
"""Initialize context."""
#: This is an attribute defined in __init__().
self.second_line_ending: Literal['\n', '\r\n', '\r'] = '\r' |
Fix #9195: autodoc: The args of `typing.Literal` are wrongly rendered
Describe the bug
Quotes are missing in the representation of typing.Literal types extracted from autodoc typehints.
To Reproduce
Steps to reproduce the behavior:
and open _build/html/project.html
Expected behavior
The Literal type should be represented as
Literal["a", "b"]
, notLiteral[a, b]
.Your project
N/A
Screenshots
Environment info
Additional context
N/A
The text was updated successfully, but these errors were encountered: