• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 20332790708

18 Dec 2025 09:48AM UTC coverage: 64.992% (-15.3%) from 80.295%
20332790708

Pull #22949

github

web-flow
Merge f730a56cd into 407284c67
Pull Request #22949: Add experimental uv resolver for Python lockfiles

54 of 97 new or added lines in 5 files covered. (55.67%)

8270 existing lines in 295 files now uncovered.

48990 of 75379 relevant lines covered (64.99%)

1.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.19
/src/python/pants/engine/addresses.py
1
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
5✔
5

6
from collections.abc import Iterable, Sequence
5✔
7
from dataclasses import dataclass
5✔
8

9
from pants.build_graph.address import Address as Address
5✔
10
from pants.build_graph.address import AddressInput as AddressInput  # noqa: F401: rexport.
5✔
11
from pants.build_graph.address import BuildFileAddress as BuildFileAddress  # noqa: F401: rexport.
5✔
12
from pants.build_graph.address import (  # noqa: F401: rexport.
5✔
13
    BuildFileAddressRequest as BuildFileAddressRequest,
14
)
15
from pants.build_graph.address import MaybeAddress as MaybeAddress  # noqa: F401: rexport.
5✔
16
from pants.build_graph.address import ResolveError
5✔
17
from pants.engine.collection import Collection
5✔
18
from pants.util.strutil import bullet_list
5✔
19

20

21
def assert_single_address(addresses: Sequence[Address]) -> None:
5✔
22
    """Assert that exactly one address must be contained in the collection."""
23
    if len(addresses) == 0:
3✔
24
        raise ResolveError("No targets were matched.")
×
25
    if len(addresses) > 1:
3✔
26
        raise ResolveError(
×
27
            "Expected a single target, but was given multiple targets.\n\n"
28
            f"Did you mean one of these?\n\n{bullet_list(address.spec for address in addresses)}"
29
        )
30

31

32
class Addresses(Collection[Address]):
5✔
33
    def expect_single(self) -> Address:
5✔
34
        assert_single_address(self)
×
35
        return self[0]
×
36

37

38
@dataclass(frozen=True)
5✔
39
class UnparsedAddressInputs:
5✔
40
    """Raw addresses that have not been parsed yet.
41

42
    You can convert these into fully normalized `Addresses` and `Targets` like this:
43

44
        await resolve_unparsed_address_inputs(UnparsedAddressInputs(["//:tgt1", "//:tgt2"], owning_address=None), **implicitly())
45
        await resolve_targets(**implicitly(UnparsedAddressInputs([...], owning_address=Address("original")))
46

47
    This is intended for contexts where the user specifies addresses outside of the `dependencies`
48
    field, such as through an option or a special field on a target that is not normal
49
    `dependencies`. You should not use this to resolve the `dependencies` field; use
50
    `await resolve_dependencies(DependenciesRequest(..), **implicitly())` for that.
51

52
    If the addresses are coming from a target's fields, set `owning_address` so that relative
53
    references like `:sibling` work properly.
54

55
    Unlike the `dependencies` field, this type does not work with `!` and `!!` ignores.
56

57
    Set `description_of_origin` to a value like "CLI arguments" or "the `dependencies` field
58
    from {tgt.address}". It is used for better error messages.
59
    """
60

61
    values: tuple[str, ...]
5✔
62
    relative_to: str | None
5✔
63
    description_of_origin: str
5✔
64
    skip_invalid_addresses: bool
5✔
65

66
    def __init__(
5✔
67
        self,
68
        values: Iterable[str],
69
        *,
70
        owning_address: Address | None,
71
        description_of_origin: str,
72
        skip_invalid_addresses: bool = False,
73
    ) -> None:
UNCOV
74
        object.__setattr__(self, "values", tuple(values))
×
UNCOV
75
        object.__setattr__(
×
76
            self, "relative_to", owning_address.spec_path if owning_address else None
77
        )
UNCOV
78
        object.__setattr__(self, "description_of_origin", description_of_origin)
×
UNCOV
79
        object.__setattr__(self, "skip_invalid_addresses", skip_invalid_addresses)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc