• 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

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

4
import logging
2✔
5
from typing import cast
2✔
6

7
from pants.engine.addresses import Address, Addresses
2✔
8
from pants.engine.console import Console
2✔
9
from pants.engine.goal import Goal, GoalSubsystem, LineOriented
2✔
10
from pants.engine.internals.graph import resolve_unexpanded_targets
2✔
11
from pants.engine.rules import collect_rules, goal_rule
2✔
12
from pants.engine.target import DescriptionField
2✔
13
from pants.option.option_types import BoolOption
2✔
14

15
logger = logging.getLogger(__name__)
2✔
16

17

18
class ListSubsystem(LineOriented, GoalSubsystem):
2✔
19
    name = "list"
2✔
20
    help = "Lists all targets matching the file or target arguments."
2✔
21

22
    documented = BoolOption(
2✔
23
        default=False,
24
        help="Print only targets that are documented with a description.",
25
    )
26

27

28
class List(Goal):
2✔
29
    subsystem_cls = ListSubsystem
2✔
30
    environment_behavior = Goal.EnvironmentBehavior.LOCAL_ONLY
2✔
31

32

33
@goal_rule
2✔
34
async def list_targets(
2✔
35
    addresses: Addresses, list_subsystem: ListSubsystem, console: Console
36
) -> List:
UNCOV
37
    if not addresses:
×
UNCOV
38
        logger.warning(f"No targets were matched in goal `{list_subsystem.name}`.")
×
UNCOV
39
        return List(exit_code=0)
×
40

UNCOV
41
    if list_subsystem.documented:
×
42
        # We must preserve target generators, not replace with their generated targets.
UNCOV
43
        targets = await resolve_unexpanded_targets(addresses)
×
UNCOV
44
        addresses_with_descriptions = cast(
×
45
            dict[Address, str],
46
            {
47
                tgt.address: tgt[DescriptionField].value
48
                for tgt in targets
49
                if tgt.get(DescriptionField).value is not None
50
            },
51
        )
UNCOV
52
        with list_subsystem.line_oriented(console) as print_stdout:
×
UNCOV
53
            for address, description in addresses_with_descriptions.items():
×
UNCOV
54
                formatted_description = "\n  ".join(description.strip().split("\n"))
×
UNCOV
55
                print_stdout(f"{address.spec}\n  {formatted_description}")
×
UNCOV
56
        return List(exit_code=0)
×
57

UNCOV
58
    with list_subsystem.line_oriented(console) as print_stdout:
×
UNCOV
59
        for address in sorted(addresses):
×
UNCOV
60
            print_stdout(address.spec)
×
UNCOV
61
    return List(exit_code=0)
×
62

63

64
def rules():
2✔
65
    return collect_rules()
2✔
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

© 2026 Coveralls, Inc