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

pantsbuild / pants / 18252174847

05 Oct 2025 01:36AM UTC coverage: 43.382% (-36.9%) from 80.261%
18252174847

push

github

web-flow
run tests on mac arm (#22717)

Just doing the minimal to pull forward the x86_64 pattern.

ref #20993

25776 of 59416 relevant lines covered (43.38%)

1.3 hits per line

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

67.74
/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
3✔
5

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

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

20

21
def assert_single_address(addresses: Sequence[Address]) -> None:
3✔
22
    """Assert that exactly one address must be contained in the collection."""
23
    if len(addresses) == 0:
×
24
        raise ResolveError("No targets were matched.")
×
25
    if len(addresses) > 1:
×
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]):
3✔
33
    def expect_single(self) -> Address:
3✔
34
        assert_single_address(self)
×
35
        return self[0]
×
36

37

38
@dataclass(frozen=True)
3✔
39
class UnparsedAddressInputs:
3✔
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, ...]
3✔
62
    relative_to: str | None
3✔
63
    description_of_origin: str
3✔
64
    skip_invalid_addresses: bool
3✔
65

66
    def __init__(
3✔
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:
74
        object.__setattr__(self, "values", tuple(values))
×
75
        object.__setattr__(
×
76
            self, "relative_to", owning_address.spec_path if owning_address else None
77
        )
78
        object.__setattr__(self, "description_of_origin", description_of_origin)
×
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