You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a type hint contains special characters (e.g. backslashes) which need to be escaped according to reStructuredText syntax, it is not correctly rendered.
To Reproduce
Steps to reproduce the behavior:
Code:
fromtypingimportLiteraldeffunc(arg: Literal['\\', '"', "'", '\n', '*', '``', ',.x']) ->Literal['\\', '"', "'", '\n', '*', '``', ',.x']:
"""My function. Args: arg: my arg Returns: my return value """returnarg#: This is a global variable.global_var: Literal['\\', '"', "'", '\n', '*', '``', ',.x'] ='\n'classContext:
"""My context class."""#: This is a class variable defined in class body.var1: Literal['\\', '"', "'", '\n', '*', '``', ',.x']
def__init__(self) ->None:
"""Initialize context."""#: This is an attribute defined in __init__().self.var2: Literal['\\', '"', "'", '\n', '*', '``', ',.x'] ='\n'
Additional context
This is not a duplicate of #9195. #9196 has fixed the stringifying of Literal, but the generated reStructuredText could still be invalid as special characters are not properly escaped. Literal is just a reasonable example to insert arbitrary characters into type hints.
The text was updated successfully, but these errors were encountered:
Describe the bug
If a type hint contains special characters (e.g. backslashes) which need to be escaped according to reStructuredText syntax, it is not correctly rendered.
To Reproduce
Steps to reproduce the behavior:
Code:
Config:
Expected behavior
The type hint
Literal['\\', '"', "'", '\n', '*', '``', ',.x']
should be correctly rendered in all places.Screenshots
![image](https://user-images.githubusercontent.com/15073518/119286501-527b5f80-bbf9-11eb-9548-ba938b35e92f.png)
Actual render:
Specifically:
\n
are missing in many places.
after the comma,
is missingEnvironment info
4.x
branch, where typing.Literal["some", "string"] types are represented incorrectly in autodocs #9195 is already fixed)Additional context
This is not a duplicate of #9195. #9196 has fixed the stringifying of
Literal
, but the generated reStructuredText could still be invalid as special characters are not properly escaped.Literal
is just a reasonable example to insert arbitrary characters into type hints.The text was updated successfully, but these errors were encountered: