Skip to main content

review.gate.excerpt

review.gate.excerpt(source, line, end_line)

The definition that holds the changed lines, numbered, the changed lines marked >.

Parameters

Name Type Description Default
source str The text of the module. required
line int The first changed line, from 1. required
end_line int The last changed line. required

Returns

Name Type Description
tuple[int, str] tuple[int, str]: The first line shown and the text. Without an enclosing definition (a module-level statement) a window of a few lines around the change.

Examples

from babregen.review.gate import excerpt

source = "X = 1\n\ndef f():\n    return 1\n"
first, text = excerpt(source, 4, 4)
print(first)
print(text)
3
     3  def f():
>    4      return 1