fix: resolve typing errors surfaced by strict downstream mypy - #329
Merged
Conversation
scikit-build-core vendors this package and type-checks it under mypy 2.x targeting Python 3.10, which flagged 7 errors introduced by the PEP 808 work that this repo's own mypy session never saw: it pinned the checker to Python 3.8, pulling the last 3.8-compatible mypy (1.14.1), whereas mypy 2.x requires a target of 3.10 or newer. Run the mypy session under Python 3.10 and set python_version = "3.10" so a regression like this is caught here going forward, and fix the errors it surfaces: - Widen the get_* helper signatures in pyproject.py from dict[str, Any] to ProjectTable (matching get_license) so the ProjectTable cast in from_pyproject is assignable; these helpers only read the mapping. - Read the dynamic loop field as a plain str, since with error collection the raw list can still hold values outside the Dynamic literal (e.g. the invalid "name") that the defensive check guards. - Drop the now-unused comparison-overlap ignore on `type_hint is Any`. Assisted-by: ClaudeCode:claude-opus-4.8
henryiii
marked this pull request as ready for review
July 3, 2026 20:21
henryiii
added a commit
to scikit-build/scikit-build-core
that referenced
this pull request
Jul 4, 2026
* chore: bump vendored pyproject-metadata to 0.12.0 Brings PEP 808 (partially-dynamic project metadata / METADATA 2.6), the PEP 685 invalid-extra-name warning, and assorted fixes. Includes the upstream typing fixes (pypa/pyproject-metadata#329) so the vendored copy type-checks cleanly under scikit-build-core's strict mypy. Assisted-by: ClaudeCode:claude-opus-4.8 * feat(metadata): emit METADATA 2.6 for PEP 808 dual-dynamic fields When a field is given a static value in [project] and also listed in project.dynamic (PEP 808), and a dynamic-metadata provider marks it as possibly changing in the wheel (dynamic_wheel), the SDist now emits Metadata-Version 2.6 with the static value alongside the Dynamic header, instead of 2.2. A dual field a provider merely extends (no dynamic_wheel) is still fully resolved into the SDist and stays pre-2.6. process_dynamic_metadata drops resolved fields from dynamic, so from_pyproject can no longer detect the dual case; the dual set is captured beforehand and re-attached to the metadata object. Assisted-by: ClaudeCode:claude-opus-4.8 * fix(metadata): skip non-string project.dynamic entries in PEP 808 scan The dual-dynamic comprehension ran membership tests on each dynamic entry before pyproject-metadata validates the list. A non-string (unhashable) entry would raise TypeError here rather than letting the library report it. Guard with isinstance so from_pyproject surfaces the config error instead. See pypa/pyproject-metadata#331 for the mirrored crash still present in the vendored library itself. Assisted-by: ClaudeCode:claude-opus-4.8 * chore: bump vendored pyproject-metadata to 0.12.1 Picks up the isinstance guard for non-string project.dynamic entries (pypa/pyproject-metadata#331), so from_pyproject now reports a collected config error instead of a raw TypeError on malformed dynamic lists. Assisted-by: ClaudeCode:claude-opus-4.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Vendoring this package into scikit-build-core and type-checking it there (mypy 2.x,
python_version = "3.10", strict) surfaced 7 typing errors in the PEP 808 code that this repo's own mypy never saw. The reason: themypynox session pinned the checker to Python 3.8, which pulls the last 3.8-compatible mypy (1.14.1), while mypy 2.x refuses any target below 3.10 and is stricter.Tightening (to catch this going forward):
mypysession under Python 3.10 (so it uses mypy 2.x).python_version = "3.10"in[tool.mypy]to pin the target explicitly.Fixes:
get_*helper signatures inpyproject.pyfromdict[str, Any]toProjectTable(matchingget_license), so theProjectTablecast infrom_pyprojectis assignable. These helpers only read the mapping.dynamicloop field as a plainstr: with error collection the raw list can still contain values outside theDynamicliteral (e.g. the invalid"name") that the existing defensive check guards against.comparison-overlapignore ontype_hint is Any.Runtime behavior is unchanged; all 403 tests pass.