Skip to content

Commit 2b54989

Browse files
committed
Cleanup
1 parent e7a1eeb commit 2b54989

File tree

2 files changed

+266
-238
lines changed

2 files changed

+266
-238
lines changed

clang-tools-extra/clang-tidy/tool/check_alphabetical_order.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@
5050
RELEASE_NOTES_DOC = os.path.join(DOCS_DIR, "ReleaseNotes.rst")
5151

5252

53+
# Label extracted from :doc:`...`.
5354
CheckLabel = str
5455
Lines = List[str]
5556
BulletBlock = List[str]
57+
58+
# Pair of the extracted label and its block
5659
BulletItem = Tuple[CheckLabel, BulletBlock]
60+
61+
# Index of the first line of a bullet block within the full lines list.
5762
BulletStart = int
5863

64+
# All occurrences for a given label.
65+
DuplicateOccurrences = List[Tuple[BulletStart, BulletBlock]]
5966

6067
class BulletBlocks(NamedTuple):
6168
"""Structured result of parsing a bullet-list section.
@@ -217,7 +224,7 @@ def sort_blocks(blocks: List[BulletItem]) -> List[BulletBlock]:
217224

218225
def find_duplicate_entries(
219226
lines: Sequence[str], title: str
220-
) -> List[Tuple[str, List[Tuple[int, List[str]]]]]:
227+
) -> List[Tuple[CheckLabel, DuplicateOccurrences]]:
221228
"""Return detailed duplicate info as (key, [(start_idx, block_lines), ...]).
222229
223230
start_idx is the 0-based index of the first line of the bullet block in
@@ -235,17 +242,17 @@ def find_duplicate_entries(
235242
while i < n and not _is_bullet_start(lines[i]):
236243
i += 1
237244

238-
blocks_with_pos: List[Tuple[str, int, List[str]]] = []
245+
blocks_with_pos: List[Tuple[CheckLabel, BulletStart, BulletBlock]] = []
239246
res = _scan_bullet_blocks(lines, i, n)
240247
for bstart, block in res.blocks_with_pos:
241248
key = extract_label(block[0])
242249
blocks_with_pos.append((key, bstart, block))
243250

244-
grouped: Dict[str, List[Tuple[int, List[str]]]] = {}
251+
grouped: Dict[CheckLabel, DuplicateOccurrences] = {}
245252
for key, start, block in blocks_with_pos:
246253
grouped.setdefault(key, []).append((start, block))
247254

248-
result: List[Tuple[str, List[Tuple[int, List[str]]]]] = []
255+
result: List[Tuple[CheckLabel, DuplicateOccurrences]] = []
249256
for key, occs in grouped.items():
250257
if len(occs) > 1:
251258
result.append((key, occs))

0 commit comments

Comments
 (0)