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
Python version (and distribution if applicable, e.g. Anaconda):
python.analysis.indexing: true
python.analysis.typeCheckingMode: basic
Code Snippet
defadd(a: int|float, b: int|float=0) ->int|float:
"""Add two numbers together Args: a (int | float): The first number b (int | float, optional): The second number. Defaults to 0. Returns: int | float: The sum of the two numbers Raises: TypeError: A parameter is not type int ValueError: foo """returna+badd(1, 2)
Repro Steps
Open a python file using vscode
Install basic python support extensions: PylancePythonPython Debugger
Define a function with Google style docstring just like the code snippets above, and then invoke it
Hover on the function call to see the popup
Expected behavior
**Returns****out**_int | float_: The sum of the two numbers
I encountered a similar (same?) issue with numpy style docstrings. dict of is incorrectly parsed as the name of the return value.
Using the same format as in the type hint works. I guess the issue has something to do with the combination of spaces and ().
Everything works if I switch off the preview feature python.analysis.supportRestructuredText.
# Does not work
def example() -> dict[str, int]:
"""
Demonstrate rendering.
Returns
-------
dict of (str, int)
Incorrectly rendered type hint.
"""
return {"key": 1}
# Works
def example() -> dict[str, int]:
"""
Demonstrate rendering.
Returns
-------
dict[str, int]
Incorrectly rendered type hint.
"""
return {"key": 1}
This rendering error still occurs with "Pylance async client (2025.2.1) started with python extension (2025.0.0)" and enabled "python.analysis.supportRestructuredText".
defexample(a: str, b: int) ->tuple[str, dict[str, int]]:
"""Example function with type hints. Args: a (str): Example input string b (int): Example input integer Returns: tuple[str, dict[str, int]]: Example output tuple """returna, {"b": b}
Environment data
Code Snippet
Repro Steps
Pylance
Python
Python Debugger
Expected behavior
Actual behavior
Logs
Addtional Info
Seems to be related to #6127 , but slightly different. The bugs in #6127 were fixed, but there are new ones here.The text was updated successfully, but these errors were encountered: