@@ -372,43 +372,6 @@ def _extract_syntax_information(exception: Exception) -> tuple[int, int]:
372372 token = ()
373373 row , column = (1 , 0 )
374374
375- if (
376- column > 0
377- and token
378- and isinstance (exception , SyntaxError )
379- and len (token ) == 4 # Python 3.9 or earlier
380- ):
381- # NOTE(sigmavirus24): SyntaxErrors report 1-indexed column
382- # numbers. We need to decrement the column number by 1 at
383- # least.
384- column_offset = 1
385- row_offset = 0
386- # See also: https://github.com/pycqa/flake8/issues/169,
387- # https://github.com/PyCQA/flake8/issues/1372
388- # On Python 3.9 and earlier, token will be a 4-item tuple with the
389- # last item being the string. Starting with 3.10, they added to
390- # the tuple so now instead of it ending with the code that failed
391- # to parse, it ends with the end of the section of code that
392- # failed to parse. Luckily the absolute position in the tuple is
393- # stable across versions so we can use that here
394- physical_line = token [3 ]
395-
396- # NOTE(sigmavirus24): Not all "tokens" have a string as the last
397- # argument. In this event, let's skip trying to find the correct
398- # column and row values.
399- if physical_line is not None :
400- # NOTE(sigmavirus24): SyntaxErrors also don't exactly have a
401- # "physical" line so much as what was accumulated by the point
402- # tokenizing failed.
403- # See also: https://github.com/pycqa/flake8/issues/169
404- lines = physical_line .rstrip ("\n " ).split ("\n " )
405- row_offset = len (lines ) - 1
406- logical_line = lines [0 ]
407- logical_line_length = len (logical_line )
408- if column > logical_line_length :
409- column = logical_line_length
410- row -= row_offset
411- column -= column_offset
412375 return row , column
413376
414377 def run_ast_checks (self ) -> None :
0 commit comments