@@ -125,11 +125,12 @@ def _process_args(self, func_ast, code_lines, args, kwargs) -> Generator[DebugAr
125125 yield self .output_class .arg_class (arg , name = ast_node .id )
126126 elif isinstance (ast_node , self .complex_nodes ):
127127 # TODO replace this hack with astor when it get's round to a new release
128- start_line , start_col = ast_node .lineno - 1 , ast_node .col_offset
129- end_line , end_col = len (code_lines ) - 1 , None
128+ start_line , start_col = arg_offsets [i ]
130129
131- if i < len (arg_offsets ) - 1 :
130+ if i + 1 < len (arg_offsets ):
132131 end_line , end_col = arg_offsets [i + 1 ]
132+ else :
133+ end_line , end_col = len (code_lines ) - 1 , None
133134
134135 name_lines = []
135136 for l in range (start_line , end_line + 1 ):
@@ -193,7 +194,12 @@ def _parse_code(self, call_frame, func_regex, filename) -> Tuple[Optional[ast.AS
193194 @classmethod
194195 def _get_offsets (cls , func_ast ):
195196 for arg in func_ast .args :
196- yield arg .lineno - 1 , arg .col_offset
197+ start_line , start_col = arg .lineno - 1 , arg .col_offset
198+
199+ # horrible hack for http://bugs.python.org/issue31241
200+ if isinstance (arg , (ast .ListComp , ast .GeneratorExp )):
201+ start_col -= 1
202+ yield start_line , start_col
197203 for kw in func_ast .keywords :
198204 yield kw .value .lineno - 1 , kw .value .col_offset - len (kw .arg ) - 1
199205
0 commit comments