Skip to content

Add offline checks to the Python lockfile API - #182

Merged
patrickballard merged 4 commits into
wheelgap:mainfrom
jwalith4418-Mj:feat/api-offline-checks
Nov 11, 2026
Merged

patrickballard merged 4 commits into
wheelgap:mainfrom
jwalith4418-Mj:feat/api-offline-checks

Conversation

@jwalith4418-Mj

@jwalith4418-Mj jwalith4418-Mj commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #172.

What this changes

Add keyword-only offline=False to check_lockfile(). With offline=True, reject inputs that need an index lookup and skip the automatic recheck for Python versions outside the lock. Those targets may show false gaps from the lock's incomplete wheel list; the README and API docstring explain that limitation. Reject online=True, offline=True before loading input.

Move the existing CLI preflight and its diagnostic helper into offline.py, shared by the CLI and API without a circular import. API errors point to offline=False; CLI messages keep their existing flag/config guidance. No changes to HTTP fetching or default checking behavior.

AI tools used: OpenAI Codex. The contributor confirmed reading commit 8e3e849 and running the checks before upload.

Validation

On Ubuntu CPython 3.14.10:

  • Five new regression cases fail on the unmodified base; the existing offline package-files control passes.
  • uv run --group dev ruff format ., ruff check ., and mypy pass.
  • uv run --group dev pytest -q: 894 passed, 1 skipped, including the existing CLI offline/config diagnostics and online API recheck cases. Tests use fake_pypi, with assertions that offline checks make no requests.
  • git diff --check passes.

The changelog credits #182. Maintainer edits are welcome. The reviewed implementation patch was rebased unchanged onto a documentation-only upstream update before submission; the final additional commit adds only the PR attribution.

Share the CLI offline preflight, reject missing file lists before lookups, and skip rechecks for Python versions outside the lock.

AI assistance: OpenAI Codex helped implement and validate this change. Contributor review is required before upload.
jwalith4418-Mj and others added 2 commits November 11, 2026 07:43
…ngelog

The README now says wheelgap.sources.SourceError, since it isn't exported
from the top-level package, and the CHANGELOG bullet says that Python
versions outside the lock may show false gaps when offline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Collaborator

Thanks, @jwalith4418-Mj! This does what #172 asked, and moving the preflight into offline.py so the CLI and the API share one check (with the CLI's messages unchanged) is nicely done.

We've made these changes so it can go in:

  • README: it now says wheelgap.sources.SourceError, since SourceError isn't exported from the top-level package and people need to know where to import it from to catch it.
  • CHANGELOG: the bullet now says that Python versions outside the lock may show false gaps when offline, as the README and the CLI note already do.

It'll merge once CI and a final review pass. Nothing is needed from you.

(Review assisted by Claude.)

@patrickballard

Copy link
Copy Markdown
Collaborator

Merged, thanks @jwalith4418-Mj! The second review confirmed that offline=True can't reach the network: the preflight uses the same test as the lookups. It also confirmed that the CLI's messages are byte-for-byte the same after the move. The one extra change: I added offline.py to the code map in AGENTS.md.

If you'd like another one, #178 builds on this. It puts the --explain reasons and the dependency path on the API's Result.

(Review assisted by Claude.)

@patrickballard
patrickballard merged commit 8596a40 into wheelgap:main Nov 11, 2026
9 checks passed
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.

Python API: check_lockfile(..., offline=True)

2 participants