MCPcopy
hub / github.com/psf/black / parse_line_ranges

Function parse_line_ranges

src/black/ranges.py:21–40  ·  view source on GitHub ↗
(line_ranges: Sequence[str])

Source from the content-addressed store, hash-verified

19
20
21def parse_line_ranges(line_ranges: Sequence[str]) -> list[tuple[int, int]]:
22 lines: list[tuple[int, int]] = []
23 for lines_str in line_ranges:
24 parts = lines_str.split("-")
25 if len(parts) != 2:
26 raise ValueError(
27 "Incorrect --line-ranges format, expect 'START-END', found"
28 f" {lines_str!r}"
29 )
30 try:
31 start = int(parts[0])
32 end = int(parts[1])
33 except ValueError:
34 raise ValueError(
35 "Incorrect --line-ranges value, expect integer ranges, found"
36 f" {lines_str!r}"
37 ) from None
38 else:
39 lines.append((start, end))
40 return lines
41
42
43def is_valid_line_range(lines: tuple[int, int]) -> bool:

Callers 2

mainFunction · 0.90
parse_modeFunction · 0.90

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected