Trelent-VSCode-Extension
Trelent-VSCode-Extension copied to clipboard
Python: Typing is not taken into account
First of all, amazing plugin, I am looking forward to its prevalence. There is an issue when brackets with or without default values appear in the Typing module variables definitions. I think it would be worthwhile to change the Regex used to parse the variables.
Example:
from typing import Tuple
def example(bla: Tuple[int, int]):
return bla[0] + bla[1]
Result:
def example(bla: Tuple[int, int]):
"""
The example function returns the sum of its two arguments.
Args:
bla: Tuple[int: Define the type of the argument
int]: Define the type of the tuple
Returns:
The sum of the two numbers in the tuple bla
Doc Author:
Trelent
"""
print('test')
return bla[0] + bla[1]
Expected:
def example(bla: Tuple[int, int]):
"""
The example function returns the sum of its two arguments.
Args:
bla: Tuple[int, int]: The two numbers
Returns:
The sum of the two numbers in the tuple bla
Doc Author:
Trelent
"""
print('test')
return bla[0]
Another example, with default arguments:
from typing import Tuple
def example(bla: Tuple[int, int]=(0, 1)):
return bla[0] + bla[1]
Result:
def example(bla: Tuple[int,int]=(0, 1)):
"""
The example function does bla.
Args:
bla: Tuple[int: Specify that the function expects a tuple of integers
int]: Specify the type of the tuple
1): Set a default value for the tuple
Returns:
The sum of the two numbers in the tuple
Doc Author:
Trelent
"""
return bla[0] + bla[1]
Expected:
def example(bla: Tuple[int, int]):
"""
The example function returns the sum of its two arguments.
Args:
bla: Tuple[int, int]: The two numbers. Defaults to (0,1).
Returns:
The sum of the two numbers in the tuple bla
Doc Author:
Trelent
"""
print('test')
return bla[0]
Thanks @VasLem! We'll take a closer look this week. Sorry for the delay here!