MCPcopy Index your code
hub / github.com/python/cpython / setup_positions

Function setup_positions

Lib/traceback.py:906–915  ·  view source on GitHub ↗

Get the lineno/col position of the end of `expr`. If `force_valid` is True, forces the position to be a valid character (e.g. if the position is beyond the end of the line, move to the next line)

(expr, force_valid=True)

Source from the content-addressed store, hash-verified

904 return lineno, col
905
906 def setup_positions(expr, force_valid=True):
907 """Get the lineno/col position of the end of `expr`. If `force_valid` is True,
908 forces the position to be a valid character (e.g. if the position is beyond the
909 end of the line, move to the next line)
910 """
911 # -2 since end_lineno is 1-indexed and because we added an extra
912 # bracket + newline to `segment` when calling ast.parse
913 lineno = expr.end_lineno - 2
914 col = normalize(lineno, expr.end_col_offset)
915 return next_valid_char(lineno, col) if force_valid else (lineno, col)
916
917 statement = tree.body[0]
918 match statement:

Calls 2

next_valid_charFunction · 0.85
normalizeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…