Skip to content

Respect uv lock environment restrictions in the repo checker - #247

Open
fbirds5230 wants to merge 4 commits into
wheelgap:mainfrom
fbirds5230:fix/239-lock-environments
Open

fbirds5230 wants to merge 4 commits into
wheelgap:mainfrom
fbirds5230:fix/239-lock-environments

Conversation

@fbirds5230

@fbirds5230 fbirds5230 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Refs #239.

Use wheelgap 0.14.0's lock_environment_targets(source, targets) to separate covered, excluded, and undecidable targets before checking the lock. An uncovered target shows “not locked”, an undecidable target shows ? with a reason, and the covered targets are still checked. Without filtering first, 0.14.0 rejects the whole request when any selected target is outside the lock's environments.

The marker parsing now belongs entirely to wheelgap, including its supported-markers list-of-strings validation. The driver no longer reads or evaluates those markers itself. Unknown and excluded targets stay out of package checks, gap counts, and suggestions. A definite requires-python exclusion still takes precedence over an undecidable environment condition.

Main is merged in, including #250's version pins and gap-wheel fallback behavior. The two conflicts in the page and its tests preserve both that behavior and the environment labels added here.

The driver tests cover invalid field types, OR/AND marker combinations, unknown conditions, and empty selections. This update adds a mixed-target check that records exactly which targets reach the library, a requires-python precedence case, and guards against invoking the package check when every selected target is excluded or undecidable.

Validation for this update:

  • All 210 site tests pass on Node 24.22.3, with no skips.
  • All seven site JavaScript syntax checks pass, as do package-note validation, Python syntax compilation of the changed driver/tests, and git diff --check.
  • The Python test suites were not run for this update: this local environment has neither pytest nor wheelgap installed. The earlier 0.13.0 run is not a validation of the current 0.14.0 integration; the repository's driver/parity CI remains the runtime check for it.

Screenshots were waived in review.

@patrickballard

Copy link
Copy Markdown
Contributor

Thanks again @fbirds5230! We reviewed this against wheelgap's own uv.lock reader and real uv 0.13.1: the rule is right for every marker the page's platforms decide, and paperless-ngx's false Windows gaps go away.

Two things before it can merge. "Allow edits by maintainers" is off on this branch too, so we can't push them ourselves; could you tick that box, or apply them?

  1. A supported-markers that isn't a list of strings (site/check/driver.py, right after the markers = tomllib.loads(...) line). A string is read character by character, so nothing is left out, and a list holding a number or a table raises TypeError out of check(), which the page doesn't catch. wheelgap refuses both, so the page should too:

                    if not isinstance(markers, list) or not all(isinstance(m, str) for m in markers):
                        raise SourceError(f"{path.name}: `supported-markers` isn't a list of strings")

    with a test in tests/test_check_driver.py:

    @pytest.mark.parametrize("value", ["\"sys_platform == 'linux'\"", "[1]", "[{ marker = \"sys_platform == 'linux'\" }]"])
    def test_uv_environments_that_arent_a_list_of_strings_are_a_source_error(repo, value):
        (repo / "uv.lock").write_text(f"supported-markers = {value}\n" + LOCK, encoding="utf-8")
        r = json.loads(driver.check(str(repo), "uv.lock", options(platforms=["linux-x86_64", "win-amd64"])))
        assert r == {"error": "uv.lock: `supported-markers` isn't a list of strings", "kind": "source"}
  2. A target the markers can't decide (a platform_release or platform_version marker, a patch-level python_full_version such as < '3.12.5', or a marker that doesn't parse). Today the PR checks such a target as normal, so the page can show gaps on a platform the lock may not support. wheelgap itself refuses those targets, and its rule is "unknown when unsure, never a guess". So please show them as ? with a short reason ("the lock's environments don't say whether this target is covered") instead of checking them. A test with one undecided marker would cover it.

The PR is still a draft; mark it ready when it's done. Screenshots aren't needed: we'll check paperless-ngx on the live page after merging.

@fbirds5230
fbirds5230 marked this pull request as ready for review November 24, 2026 00:19
@patrickballard

Copy link
Copy Markdown
Contributor

Thanks for the quick follow-up, @fbirds5230! Both requested changes are in: a supported-markers that isn't a list of strings is now a source error, and targets the markers can't decide show as ? with a reason instead of being checked. This looks good overall. Because it's over 400 changed lines, Patrick will do the final review and merge it himself.

(Review assisted by Claude.)

@patrickballard

Copy link
Copy Markdown
Contributor

@fbirds5230, a heads-up: the checker now runs wheelgap 0.14.0 (#250), which reads [tool.uv] environments itself. On paperless-ngx the page no longer shows the false Windows gaps; instead wheelgap refuses a target the lock doesn't cover, and the page shows that error for the whole check.

So part of this PR is now built in. What it still adds is the better answer: mark an uncovered target as "not locked" (and an undecided one as ?) while the covered targets are still checked, instead of refusing everything. When you pick it back up:

  • Merge main in. It conflicts in site/check/check.mjs and tests/site/check-page.test.mjs.
  • Replace the driver's own supported-markers parsing with wheelgap 0.14.0's check.lock_environment_targets(source, targets), which has the same rules (any marker holding covers a target; an unknown marker leaves it undecided).
  • Keep passing only the covered targets to the check, so it doesn't refuse.

The two points from my earlier comment still apply. Thanks for sticking with it!

@patrickballard

Copy link
Copy Markdown
Contributor

Thanks for picking this back up so quickly, @fbirds5230! The update looks good overall: main is merged in, the driver now uses wheelgap 0.14.0's lock_environment_targets() instead of its own marker parsing, and only covered targets reach the library check, with excluded ones shown as "not locked" and undecided ones as ?. Because it's still over 400 changed lines, Patrick will do the final review and merge it himself.

(Review assisted by Claude.)

This branch has not been deployed

No deployments
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.

2 participants