This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Python: Typing is not taken into account #11
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request