Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove source and version from dependencies in lock file when unambiguous #4513

Merged
merged 3 commits into from
Jun 26, 2024

Commits on Jun 26, 2024

  1. uv-resolver: refactor lock data type deserialization

    This commit prepares to make the `source` and `version` fields optional
    in a `distribution.dependency` based on whether they have an unambiguous
    value. e.g., When there is exactly one distribution with a matching
    package name.
    
    This refactor effectively defines "wire" types for most of the lock data
    types (repeating the `WheelWire` and `LockWire` pattern) with one key
    difference: we don't use serde's `TryFrom` integration. In this
    refactor, we could have, and it would have worked. But in a subsequent
    commit, we're going to be adding state to the `unwire()` calls that is
    impossible to thread through a `TryFrom` implementation. This state will
    tell us how to populate the `source` and `version` values on a
    `Dependency` when they're missing.
    
    The duplication of types here is unfortunate, but compiler should catch
    any deviations. And the wire types are unexported, so they have a
    limited blast radius on complexity.
    BurntSushi committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    b456240 View commit details
    Browse the repository at this point in the history
  2. uv-resolver: support unambiguous omission of 'source' and 'version'

    When there is only one distribution for a particular package name, any
    dependencies (the edges in the resolution graph) that reference that
    package name are completely unambiguous. Therefore, we can actually omit
    their version and source information and instead derive it from the
    distribution entry.
    
    We add some tests to check the success and error cases. That is, when
    `source` or `version` are omitted and there are more than one
    corresponding distribution for the package name (i.e., it's ambiguous),
    then lock deserialization should fail.
    BurntSushi committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    529a874 View commit details
    Browse the repository at this point in the history
  3. uv/tests: update lock file snapshots

    This update follows from the removal of of `source` and `version` from
    `distribution.dependency` entries in the lock file when the package name
    unambiguously refers to a single distribution.
    BurntSushi committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    c9a918f View commit details
    Browse the repository at this point in the history