Skip to content

fix(about): make about.py metadata lookup type-checker-proof - #122

Merged
woutervh merged 1 commit into
mainfrom
fix/ty-0.0.29-about
Aug 30, 2026
Merged

woutervh merged 1 commit into
mainfrom
fix/ty-0.0.29-about

Conversation

@woutervh

@woutervh woutervh commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Why

Dependabot #103 (bump ty 0.0.19 -> 0.0.29) turns the Linting job red on
every Python version. ty check rejects two constructs in
src/autoadd_bindir/about.py that older ty accepted and that
# type: ignore[...] comments do not silence:

  1. unresolved-attribute - msg.json (typeshed resolves
    importlib.metadata.metadata() as email.message.Message, which has no .json).
  2. invalid-assignment - version: str = pkginfo.get("version", "unknown")
    (the value is str | list[str]).

What

Materialise the distribution metadata into a plain dict[str, str] with
{key: msg[key] for key in msg} - only __iter__ (over keys) and __getitem__
are guaranteed on importlib.metadata.PackageMetadata across 3.9-3.14, unlike
.json or .get (mypy 1.19 rejects .get on 3.10/3.11). Then read
Author-email / License(-Expression) / Version off the dict. Fallback
branches keep their # pragma: no cover.

Single-file change; uv.lock is untouched here.

Verification (local)

Against ty 0.0.75 (newer than #103's 0.0.29): just ruff-check,
just pylint (10/10), just mypy (explicitly on 3.10 / 3.11 / 3.14),
just ty-check, pre-commit run --all-files, and just pytest-coverage
(100%, 7 passed) all pass.

Follow-up

Merging this unblocks #103; that PR then only carries the ty lockfile bump.

@woutervh
woutervh force-pushed the fix/ty-0.0.29-about branch from fbd41a8 to d2f7a5c Compare August 30, 2026 14:36
Dependabot #103 (bump `ty` 0.0.19 -> 0.0.29) turns the Linting job red
on every Python version. `ty` rejects two constructs in `about.py` that
older `ty` accepted and that `# type: ignore[...]` does not silence:

- `msg.json` -> `unresolved-attribute` (typeshed resolves
  `importlib.metadata.metadata()` as `email.message.Message`).
- `version: str = pkginfo.get("version", "unknown")` -> `invalid-assignment`
  (the value is `str | list[str]`).

Materialise the distribution metadata into a plain `dict[str, str]` via
`{key: msg[key] for key in msg}` - only `__iter__` (over keys) and
`__getitem__` are guaranteed on `PackageMetadata` across 3.9-3.14, unlike
`.json` / `.get` - then read `Author-email` / `License(-Expression)` /
`Version` off the dict. Fallback branches keep their `# pragma: no cover`.

Verified against `ty` 0.0.75 locally (plus ruff, pylint 10/10, mypy on
3.10/3.11/3.14, pre-commit, pytest+coverage 100%). Merging unblocks #103,
which then only carries the lockfile bump.
@woutervh
woutervh force-pushed the fix/ty-0.0.29-about branch from d2f7a5c to 3619fd8 Compare August 30, 2026 14:37
@woutervh woutervh changed the title fix(about): make about.py type-clean for ty 0.0.29 fix(about): make about.py metadata lookup type-checker-proof Aug 30, 2026
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (07ce174) to head (3619fd8).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #122   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           24        24           
=========================================
  Hits            24        24           
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@woutervh
woutervh merged commit 2ff4ca3 into main Aug 30, 2026
18 checks passed
@woutervh
woutervh deleted the fix/ty-0.0.29-about branch August 30, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant