You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(pypi)!: private Python indexes from lockfiles; drop pip requirements - #164
Phase 3 of #157, PyPI. A Python package can now come from a private index. This builds on PackageId from #162.
Where a package's index comes from: its lockfile
uv.lock (at the uv workspace root for members; a member's own lockfile is ignored) and poetry.lock record each package's index. The Count uses what they record; entries that disagree are ambiguous.
A package no lockfile records is PyPI's only when the project configures no index at all. Otherwise its lookup fails, asking for a lockfile that records it.
Settings are read only to tell whether any index is configured. uv and Poetry settings use strict types; every uv setting is classified, checked against uv's own list, and Poetry's keys against its schema.
Anything unreadable fails every lookup, locked or not: unknown keys, unparsable files, symlinked or unreadable settings, uncertain workspace globs, and PDM, Rye, Pixi or Hatch index settings.
Packages a manifest takes from git, a path, a URL or a workspace member are listed as skipped.
A stale lockfile is caught by the update, which runs the real uv lock or poetry lock.
Earlier revisions predicted the index from each tool's settings; reviews kept finding places where that copy of uv's and Poetry's resolution disagreed with the tools, so the lockfile now decides.
Removed: pip requirements files
The requirements manager is gone (breaking: managers no longer accepts requirements). pip takes each package from whatever index a file's options, includes and environment name; each requirements file is listed as skipped, recommending uv.
Private indexes
Read through the simple API as PEP 691 JSON or PEP 503 HTML, with operator credentials and mirrors, keeping only the requested project's files. Secrets in index URLs are never recorded (URL parsing with a randomised test).
Tests
real_python_indexes: generated uv and Poetry projects resolved by the real tools, then read by the Count with the lockfile they wrote; key lists checked against uv and Poetry.
Extraction tests for lockfile decisions, fail-closed settings, secrets and skipped packages.
A Python package's registry is its pin (uv `[tool.uv.sources]`, a Poetry
dependency's `source`), else the index its lockfile records (`uv.lock`,
`poetry.lock`), else the only index the project names (pip `--index-url`,
a uv default index or `index-url`, a Poetry primary source; a `uv.toml`
replaces `[tool.uv]`). A package that could come from several indexes is
ambiguous: its lookup fails asking for a pin or a lockfile, and it never
falls back to PyPI, where the same name may be someone else's.
Private indexes are read through their simple API, as PEP 691 JSON or PEP
503 HTML. PyPI extractors take a `registry` template. Registry lookups
that cannot run say why. The extraction cache key moves to v13.
Refs #157
We reviewed changes in f737a97...515f977 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
The reason will be displayed to describe this comment to others. Learn more.
Use of `unwrap_or` followed by function call, prefer `unwrap_or_else` instead
Calls to unwrap_or followed by a function call should be replaced with unwrap_or_else or unwrap_or_default, to increase laziness. The argument to unwrap_or is evaluated eagerly and unconditionally. unwrap_or_else or unwrap_or_default are evaluated lazily and only if required, sometimes
leading to lower overhead and fewer allocations.
From review:
- `[tool.uv.sources]` pins come from the project and its workspace root
whatever a `uv.toml` says; index settings come from the nearest
`uv.toml` or `[tool.uv]`, as uv reads them.
- Packages from git, a path, a URL or a workspace member, pinned or
locked, are left alone instead of looked up on PyPI. Marker-split pins
to several indexes, and lock entries that disagree, are ambiguous.
- Requirements files share index options across `-r`/`-c` includes;
`--find-links` adds a non-index source and `--no-index` stops lookups.
- A pin to an undefined index fails; Poetry names match without case,
and a URL-less PyPI source is PyPI.
- Only the project's own lockfile, or its workspace root's, counts.
- The HTML simple-page parser handles case, quoted `>` and entities.
The corpus drops pydantic's workspace member `pydantic-core`.
The reason will be displayed to describe this comment to others. Learn more.
Use of `unwrap_or` followed by function call, prefer `unwrap_or_else` instead
Calls to unwrap_or followed by a function call should be replaced with unwrap_or_else or unwrap_or_default, to increase laziness. The argument to unwrap_or is evaluated eagerly and unconditionally. unwrap_or_else or unwrap_or_default are evaluated lazily and only if required, sometimes
leading to lower overhead and fewer allocations.
The reason will be displayed to describe this comment to others. Learn more.
Reverted: clippy (unnecessary_lazy_evaluations, which CI enforces with -D warnings) rejects the closure here, since building Origin::Index(Named::Public) costs nothing.
The reason will be displayed to describe this comment to others. Learn more.
Use of `unwrap_or` followed by function call, prefer `unwrap_or_else` instead
Calls to unwrap_or followed by a function call should be replaced with unwrap_or_else or unwrap_or_default, to increase laziness. The argument to unwrap_or is evaluated eagerly and unconditionally. unwrap_or_else or unwrap_or_default are evaluated lazily and only if required, sometimes
leading to lower overhead and fewer allocations.
From a second review:
- Every pyproject.toml, uv.toml, uv.lock and poetry.lock is fetched when
pyproject is on, and every .txt/.in outside `exclude` when requirements
is, whatever `files` selects, so a workspace root or `-r` target is never
missed.
- Requirements options come only from .txt/.in files, parsed once per
scan; joined short options and line continuations are read.
- Registry values the Count cannot use are recorded without user,
password or query, for npm and PyPI alike.
- Poetry's built-in `pypi` source counts as PyPI.
- Packages from git, a path, a URL or a workspace member are reported as
skipped.
Docs: `--no-index` fails lookups; requirements files read only their own
options; PDM sources are not read yet.
Requirements includes are fetched by following -r and -c rather than
reading every text file, and a file takes the options of each pip run
that reads it. An include the Count cannot read makes its run ambiguous.
uv workspace members take index settings from their root, membership
follows members and exclude, find-links, flat indexes and no-index are
read, and an unparsable pyproject.toml or uv.toml above a project fails
its lookups. PDM sources are read. Redaction handles a slash in a
password and a query with no path.
Workspace membership uses the nearest root and normalises ./ and
trailing slashes in its globs. Requirements runs start from every file
named like one, even an excluded one, and the default name pattern
takes dev-requirements.txt and the like. Includes through symlinks stay
unread, at most 256 are fetched, concurrently, and a failed fetch leaves
the include unread instead of failing the scan. A byte order mark and
quoted include paths are read as pip reads them. Redaction drops a
password holding ? or #, and an unusable registry fails without a
request.
The Count now reads a fixed list of pip options, uv settings and index
keys, Poetry and PDM source keys and pin keys, and anything else that
could move a package makes its lookup fail instead of falling back to
PyPI. Pins that hold only under markers, extras, groups or Pythons are
ambiguous. Redaction parses URLs with the url crate and records
<unreadable URL> for any it cannot split cleanly, with a randomised test
that no secret survives. A real_ test resolves fixtures with uv, pip and
Poetry against a local index server and checks the Count's choice of
index against theirs.
…ements
uv and Poetry index settings are read into types that describe every
key the Count understands and reject the rest, so [[x]] and inline
arrays read alike and nothing is skipped unread. Every setting uv
accepts is classified as read or irrelevant, and real_ tests check the
lists against uv's own and Poetry's schemas. PDM, Rye, Pixi and Hatch
settings that could name an index fail closed. A lockfile entry for an
index the project no longer searches is ambiguous, as is a uv.lock
entry without a source. A generated real_ test compares the Count's
choice of index with uv's and Poetry's across declaration forms, roles,
pin forms and workspace layouts.
The requirements manager is removed: pip's index can be set by options,
includes and the environment in ways the Count cannot settle from the
repository. A repository with pip requirements files gets a warning
recommending a move to uv.
The reason will be displayed to describe this comment to others. Learn more.
Use of `unwrap_or` followed by function call, prefer `unwrap_or_else` instead
Calls to unwrap_or followed by a function call should be replaced with unwrap_or_else or unwrap_or_default, to increase laziness. The argument to unwrap_or is evaluated eagerly and unconditionally. unwrap_or_else or unwrap_or_default are evaluated lazily and only if required, sometimes
leading to lower overhead and fewer allocations.
The reason will be displayed to describe this comment to others. Learn more.
Use of `unwrap_or` followed by function call, prefer `unwrap_or_else` instead
Calls to unwrap_or followed by a function call should be replaced with unwrap_or_else or unwrap_or_default, to increase laziness. The argument to unwrap_or is evaluated eagerly and unconditionally. unwrap_or_else or unwrap_or_default are evaluated lazily and only if required, sometimes
leading to lower overhead and fewer allocations.
The reason will be displayed to describe this comment to others. Learn more.
Using match to destructure a single pattern: `(Some(members), Some(exclude))`, prefer an `if-let-else`
match statements with only one useful arm can be reduced to an if-else statement.
This helps improve readability, an if-else statement nests lesser than a match.
Whether a lock entry without a source means PyPI depends on the tool
that wrote it, so the lockfile's name decides, not its contents. Fixtures
now carry the source uv always writes.
…rements files quietly
uv's [pip] table names indexes uv pip reads for the project, so they are
candidates. A lockfile counts only when its tool could have written it,
and a project with both [tool.uv] and [tool.poetry] takes both tools'
indexes as candidates. Conflicting pins across Poetry groups are
ambiguous. PDM, Rye, Pixi and Hatch settings fail closed in any ancestor
and in pdm.toml, pixi.toml and hatch.toml, and a settings file behind a
symlink or not in UTF-8 is unreadable, not absent. Workspace globs use
globset as filesystem globs do, a URL's scheme is case-insensitive, and a
private index page lends a project only its own files' versions.
pip requirements files are reported as skipped rather than as a
warning, which would have held back branch cleanup and automerge. The
real-tool test now checks that a PyPI expectation reached PyPI, covers
overrides, no-sources and root pins, and checks uv's [pip] keys; it
showed that uv ignores overrides in uv.toml when locking.
Working out which index uv or Poetry would pick from their settings
meant re-implementing each tool's resolution, and every review found
another place the copy disagreed with the tool. The lockfile is the
tool's own answer: a package uv.lock or poetry.lock records comes from
what it records, uv's taken at the workspace root. A package no lockfile
records is PyPI's only where the project configures no index at all;
elsewhere its lookup fails until a lockfile records it. Settings are
read only to tell whether any index is configured, and anything the
Count cannot read still fails every lookup, locked or not. A stale lock
is caught by the update itself, which runs the real tool with the
project's settings.
Packages from git, a path, a URL or a workspace member, by source, by
Poetry dependency or by a name @ url requirement, are reported as
skipped. Requirements files are listed as skipped rather than as a
warning, and an unreadable local settings file counts as unreadable.
sweepies
changed the title
feat(pypi): look Python packages up in the index the project pins
feat(pypi)!: private Python indexes from lockfiles; drop pip requirements
Nov 3, 2026
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
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.
Phase 3 of #157, PyPI. A Python package can now come from a private index. This builds on
PackageIdfrom #162.Where a package's index comes from: its lockfile
uv.lock(at the uv workspace root for members; a member's own lockfile is ignored) andpoetry.lockrecord each package's index. The Count uses what they record; entries that disagree are ambiguous.uv lockorpoetry lock.Earlier revisions predicted the index from each tool's settings; reviews kept finding places where that copy of uv's and Poetry's resolution disagreed with the tools, so the lockfile now decides.
Removed: pip requirements files
The
requirementsmanager is gone (breaking:managersno longer acceptsrequirements). pip takes each package from whatever index a file's options, includes and environment name; each requirements file is listed as skipped, recommending uv.Private indexes
Read through the simple API as PEP 691 JSON or PEP 503 HTML, with operator credentials and mirrors, keeping only the requested project's files. Secrets in index URLs are never recorded (URL parsing with a randomised test).
Tests
real_python_indexes: generated uv and Poetry projects resolved by the real tools, then read by the Count with the lockfile they wrote; key lists checked against uv and Poetry.