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

pantsbuild / pants / 18517631058

15 Oct 2025 04:18AM UTC coverage: 69.207% (-11.1%) from 80.267%
18517631058

Pull #22745

github

web-flow
Merge 642a76ca1 into 99919310e
Pull Request #22745: [windows] Add windows support in the stdio crate.

53815 of 77759 relevant lines covered (69.21%)

2.42 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
3✔
5
from typing import cast
3✔
6

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

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

17

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

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

27

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

32

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

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

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

63

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