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

pantsbuild / pants / 21552830208

31 Jan 2026 11:40PM UTC coverage: 80.277% (-0.05%) from 80.324%
21552830208

Pull #23062

github

web-flow
Merge 808a9786c into 2c4dcf9cf
Pull Request #23062: Remove support for Get

18 of 25 new or added lines in 4 files covered. (72.0%)

17119 existing lines in 541 files now uncovered.

78278 of 97510 relevant lines covered (80.28%)

3.36 hits per line

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

100.0
/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

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

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

UNCOV
15
logger = logging.getLogger(__name__)
6✔
16

17

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

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

27

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

32

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

UNCOV
41
    if list_subsystem.documented:
1✔
42
        # We must preserve target generators, not replace with their generated targets.
UNCOV
43
        targets = await resolve_unexpanded_targets(addresses)
1✔
UNCOV
44
        addresses_with_descriptions = cast(
1✔
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:
1✔
UNCOV
53
            for address, description in addresses_with_descriptions.items():
1✔
UNCOV
54
                formatted_description = "\n  ".join(description.strip().split("\n"))
1✔
UNCOV
55
                print_stdout(f"{address.spec}\n  {formatted_description}")
1✔
UNCOV
56
        return List(exit_code=0)
1✔
57

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

63

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