Skip to content

Commit ab020ba

Browse files
committed
~
1 parent 6e96165 commit ab020ba

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,32 @@
3232
import re
3333
import sys
3434
from typing import (
35+
DefaultDict,
36+
Final,
37+
Iterable,
3538
List,
39+
NamedTuple,
3640
Optional,
3741
Sequence,
3842
Tuple,
39-
NamedTuple,
40-
DefaultDict,
41-
Final,
42-
Pattern,
4343
)
4444

4545
# Matches a :doc:`label <path>` or :doc:`label` reference anywhere in text and
4646
# captures the label. Used to sort bullet items alphabetically in ReleaseNotes
4747
# items by their label.
48-
DOC_LABEL_RN_RE: Final[Pattern[str]] = re.compile(
49-
r":doc:`(?P<label>[^`<]+)\s*(?:<[^>]+>)?`"
50-
)
48+
DOC_LABEL_RN_RE: Final = re.compile(r":doc:`(?P<label>[^`<]+)\s*(?:<[^>]+>)?`")
5149

5250
# Matches a single csv-table row line in list.rst that begins with a :doc:
5351
# reference, capturing the label. Used to extract the sort key per row.
54-
DOC_LINE_RE: Final[Pattern[str]] = re.compile(
55-
r"^\s*:doc:`(?P<label>[^`<]+?)\s*<[^>]+>`.*$"
56-
)
52+
DOC_LINE_RE: Final = re.compile(r"^\s*:doc:`(?P<label>[^`<]+?)\s*<[^>]+>`.*$")
5753

5854

59-
EXTRA_DIR: Final[str] = os.path.join(os.path.dirname(__file__), "../..")
60-
DOCS_DIR: Final[str] = os.path.join(EXTRA_DIR, "docs")
61-
CLANG_TIDY_DOCS_DIR: Final[str] = os.path.join(DOCS_DIR, "clang-tidy")
62-
CHECKS_DOCS_DIR: Final[str] = os.path.join(CLANG_TIDY_DOCS_DIR, "checks")
63-
LIST_DOC: Final[str] = os.path.join(CHECKS_DOCS_DIR, "list.rst")
64-
RELEASE_NOTES_DOC: Final[str] = os.path.join(DOCS_DIR, "ReleaseNotes.rst")
55+
EXTRA_DIR: Final = os.path.join(os.path.dirname(__file__), "../..")
56+
DOCS_DIR: Final = os.path.join(EXTRA_DIR, "docs")
57+
CLANG_TIDY_DOCS_DIR: Final = os.path.join(DOCS_DIR, "clang-tidy")
58+
CHECKS_DOCS_DIR: Final = os.path.join(CLANG_TIDY_DOCS_DIR, "checks")
59+
LIST_DOC: Final = os.path.join(CHECKS_DOCS_DIR, "list.rst")
60+
RELEASE_NOTES_DOC: Final = os.path.join(DOCS_DIR, "ReleaseNotes.rst")
6561

6662

6763
# Label extracted from :doc:`...`.
@@ -232,7 +228,7 @@ def _parse_bullet_blocks(lines: Sequence[str], start: int, end: int) -> BulletBl
232228
return BulletBlocks(prefix, blocks, suffix)
233229

234230

235-
def sort_blocks(blocks: List[BulletItem]) -> List[BulletBlock]:
231+
def sort_blocks(blocks: Iterable[BulletItem]) -> List[BulletBlock]:
236232
"""Return blocks sorted deterministically by their extracted label.
237233
238234
Duplicates are preserved; merging is left to authors to handle manually.

0 commit comments

Comments
 (0)