|
32 | 32 | import re |
33 | 33 | import sys |
34 | 34 | from typing import ( |
| 35 | + DefaultDict, |
| 36 | + Final, |
| 37 | + Iterable, |
35 | 38 | List, |
| 39 | + NamedTuple, |
36 | 40 | Optional, |
37 | 41 | Sequence, |
38 | 42 | Tuple, |
39 | | - NamedTuple, |
40 | | - DefaultDict, |
41 | | - Final, |
42 | | - Pattern, |
43 | 43 | ) |
44 | 44 |
|
45 | 45 | # Matches a :doc:`label <path>` or :doc:`label` reference anywhere in text and |
46 | 46 | # captures the label. Used to sort bullet items alphabetically in ReleaseNotes |
47 | 47 | # 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*(?:<[^>]+>)?`") |
51 | 49 |
|
52 | 50 | # Matches a single csv-table row line in list.rst that begins with a :doc: |
53 | 51 | # 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*<[^>]+>`.*$") |
57 | 53 |
|
58 | 54 |
|
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") |
65 | 61 |
|
66 | 62 |
|
67 | 63 | # Label extracted from :doc:`...`. |
@@ -232,7 +228,7 @@ def _parse_bullet_blocks(lines: Sequence[str], start: int, end: int) -> BulletBl |
232 | 228 | return BulletBlocks(prefix, blocks, suffix) |
233 | 229 |
|
234 | 230 |
|
235 | | -def sort_blocks(blocks: List[BulletItem]) -> List[BulletBlock]: |
| 231 | +def sort_blocks(blocks: Iterable[BulletItem]) -> List[BulletBlock]: |
236 | 232 | """Return blocks sorted deterministically by their extracted label. |
237 | 233 |
|
238 | 234 | Duplicates are preserved; merging is left to authors to handle manually. |
|
0 commit comments