File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -849,13 +849,18 @@ def _remove_type_bracket_block_from_args_str(args_str: str):
849849 return args_str
850850 bracket_count : int = 0
851851 result_str : str = ''
852+ is_type_block : bool = False
852853 for char in args_str :
853- if char == '[' :
854+ if bracket_count == 0 and char == ':' :
855+ is_type_block = True
856+ if is_type_block and char == '[' :
854857 bracket_count += 1
855858 continue
856- if char == ']' :
859+ if is_type_block and char == ']' :
857860 bracket_count -= 1
858861 continue
862+ if bracket_count == 0 and (char == ',' or char == '=' ):
863+ is_type_block = False
859864 if bracket_count != 0 :
860865 continue
861866 result_str += char
Original file line number Diff line number Diff line change @@ -1809,3 +1809,14 @@ def test__remove_type_bracket_block_from_args_str():
18091809 'dict_val: Optional = None, tuple_val: Optional=None'
18101810 )
18111811 assert result_str == expected_str
1812+
1813+ args_str : str = (
1814+ 'list_val_1: List[int],'
1815+ ' list_val_2: Optional[List[int]] = [100, 200]'
1816+ )
1817+ result_str = helper ._remove_type_bracket_block_from_args_str (
1818+ args_str = args_str )
1819+ expected_str = (
1820+ 'list_val_1: List, list_val_2: Optional = [100, 200]'
1821+ )
1822+ assert result_str == expected_str
You can’t perform that action at this time.
0 commit comments