Skip to content

Commit 71785ae

Browse files
committed
typing(refactor[versions]) Describe the PEP 440 local sort key
why: The previous local checker command enumerated the vendored parser explicitly, including files that the old CI discovery excluded. what: - Distinguish parsed local segments from the tagged tuples produced for sorting and describe all returned segments. - Keep the full parser in the local and CI type gates and retain explicit signature checks for these files.
1 parent dad263c commit 71785ae

4 files changed

Lines changed: 8 additions & 15 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ jobs:
4848
run: uv run ruff format . --check
4949

5050
- name: Check types with ty
51-
run: uv run ty check --python-version "${{ matrix.python-version }}"
51+
run: |
52+
uv run ty check --python-version "${{ matrix.python-version }}"
53+
uv run ruff check --select ANN001,ANN002,ANN003,ANN201,ANN202,ANN204,ANN205,ANN206 src/libvcs/_vendor/*.py
5254
5355
- name: Print python versions
5456
run: |

‎justfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ watch-ruff:
9292
[group: 'lint']
9393
ty:
9494
uv run ty check
95+
uv run ruff check --select ANN001,ANN002,ANN003,ANN201,ANN202,ANN204,ANN205,ANN206 src/libvcs/_vendor/*.py
9596

9697
# Watch maintained Python files for typing changes
9798
[group: 'lint']

‎pyproject.toml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,6 @@ sphinx-ux-badges = false
147147
[tool.ty.environment]
148148
python-version = "3.11"
149149

150-
[tool.ty.src]
151-
exclude = ["src/libvcs/_vendor"]
152-
153150
[tool.ty.terminal]
154151
error-on-warning = true
155152

‎src/libvcs/_vendor/version.py‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,10 @@
2323

2424
InfiniteTypes = t.Union[InfinityType, NegativeInfinityType]
2525
PrePostDevType = t.Union[InfiniteTypes, tuple[str, int]]
26-
SubLocalType = t.Union[InfiniteTypes, int, str]
26+
SubLocalType = t.Union[int, str]
2727
LocalType = t.Union[
2828
NegativeInfinityType,
29-
tuple[
30-
t.Union[
31-
SubLocalType,
32-
tuple[SubLocalType, str],
33-
tuple[NegativeInfinityType, SubLocalType],
34-
],
35-
...,
36-
],
29+
tuple[t.Union[tuple[int, str], tuple[NegativeInfinityType, str]], ...],
3730
]
3831
CmpKey = tuple[
3932
int,
@@ -515,7 +508,7 @@ def _parse_letter_version(
515508
_local_version_separators = re.compile(r"[\._-]")
516509

517510

518-
def _parse_local_version(local: str) -> LocalType | None:
511+
def _parse_local_version(local: str | None) -> tuple[SubLocalType, ...] | None:
519512
"""Take a string like abc.1.twelve and turns it into ("abc", 1, "twelve")."""
520513
if local is not None:
521514
return tuple(
@@ -531,7 +524,7 @@ def _cmpkey(
531524
pre: tuple[str, int] | None,
532525
post: tuple[str, int] | None,
533526
dev: tuple[str, int] | None,
534-
local: tuple[SubLocalType] | None,
527+
local: tuple[SubLocalType, ...] | None,
535528
) -> CmpKey:
536529
# When we compare a release version, we want to compare it with all of the
537530
# trailing zeros removed. So we'll use a reverse the list, drop all the now

0 commit comments

Comments
 (0)