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

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

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

0.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
×
UNCOV
5
from typing import cast
×
6

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

UNCOV
15
logger = logging.getLogger(__name__)
×
16

17

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

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

27

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

32

UNCOV
33
@goal_rule
×
UNCOV
34
async def list_targets(
×
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

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