• 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/count_loc.py
1
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
UNCOV
3
from pants.core.goals.resolves import ExportableTool
×
UNCOV
4
from pants.core.util_rules.external_tool import TemplatedExternalTool, download_external_tool
×
UNCOV
5
from pants.engine.console import Console
×
UNCOV
6
from pants.engine.fs import MergeDigests, PathGlobs, SpecsPaths
×
UNCOV
7
from pants.engine.goal import Goal, GoalSubsystem
×
UNCOV
8
from pants.engine.intrinsics import merge_digests, path_globs_to_digest
×
UNCOV
9
from pants.engine.platform import Platform
×
UNCOV
10
from pants.engine.process import Process, execute_process_or_raise
×
UNCOV
11
from pants.engine.rules import collect_rules, concurrently, goal_rule, implicitly
×
UNCOV
12
from pants.engine.unions import UnionRule
×
UNCOV
13
from pants.option.option_types import ArgsListOption
×
UNCOV
14
from pants.util.logging import LogLevel
×
UNCOV
15
from pants.util.strutil import pluralize
×
16

17

UNCOV
18
class SuccinctCodeCounter(TemplatedExternalTool):
×
UNCOV
19
    options_scope = "scc"
×
UNCOV
20
    name = "SCC"
×
UNCOV
21
    help = "The Succinct Code Counter, aka `scc` (https://github.com/boyter/scc)."
×
22

UNCOV
23
    default_version = "3.0.0"
×
UNCOV
24
    default_known_versions = [
×
25
        "3.0.0|macos_arm64 |846cb1b25025a0794d455719bc17cfb3f588576a58af1d95036f6c654e294f98|2006145",
26
        "3.0.0|macos_x86_64|9c3064e477ab36e16204ad34f649372034bca4df669615eff5de4aa05b2ddf1a|2048134",
27
        "3.0.0|linux_arm64 |04f9e797b70a678833e49df5e744f95080dfb7f963c0cd34f5b5d4712d290f33|1768037",
28
        "3.0.0|linux_x86_64|13ca47ce00b5bd032f97f3af7aa8eb3c717b8972b404b155a378b09110e4aa0c|1948341",
29
    ]
UNCOV
30
    default_url_template = (
×
31
        "https://github.com/boyter/scc/releases/download/v{version}/scc-{version}-{platform}.zip"
32
    )
UNCOV
33
    default_url_platform_mapping = {
×
34
        "macos_arm64": "arm64-apple-darwin",
35
        "macos_x86_64": "x86_64-apple-darwin",
36
        "linux_arm64": "arm64-unknown-linux",
37
        "linux_x86_64": "x86_64-unknown-linux",
38
    }
39

UNCOV
40
    args = ArgsListOption(
×
41
        example="--no-cocomo",
42
        passthrough=True,
43
        extra_help="Refer to to https://github.com/boyter/scc.",
44
    )
45

UNCOV
46
    def generate_exe(self, _: Platform) -> str:
×
47
        return "./scc"
×
48

49

UNCOV
50
class CountLinesOfCodeSubsystem(GoalSubsystem):
×
UNCOV
51
    name = "count-loc"
×
UNCOV
52
    help = "Count lines of code."
×
53

54

UNCOV
55
class CountLinesOfCode(Goal):
×
UNCOV
56
    subsystem_cls = CountLinesOfCodeSubsystem
×
UNCOV
57
    environment_behavior = Goal.EnvironmentBehavior.LOCAL_ONLY
×
58

59

UNCOV
60
@goal_rule
×
UNCOV
61
async def count_loc(
×
62
    console: Console,
63
    succinct_code_counter: SuccinctCodeCounter,
64
    specs_paths: SpecsPaths,
65
    platform: Platform,
66
) -> CountLinesOfCode:
67
    if not specs_paths.files:
×
68
        return CountLinesOfCode(exit_code=0)
×
69

70
    specs_digest, scc_program = await concurrently(
×
71
        path_globs_to_digest(PathGlobs(globs=specs_paths.files)),
72
        download_external_tool(succinct_code_counter.get_request(platform)),
73
    )
74
    input_digest = await merge_digests(MergeDigests((scc_program.digest, specs_digest)))
×
75
    result = await execute_process_or_raise(
×
76
        **implicitly(
77
            Process(
78
                argv=(scc_program.exe, *succinct_code_counter.args),
79
                input_digest=input_digest,
80
                description=f"Count lines of code for {pluralize(len(specs_paths.files), 'file')}",
81
                level=LogLevel.DEBUG,
82
            )
83
        )
84
    )
85
    console.print_stdout(result.stdout.decode())
×
86
    return CountLinesOfCode(exit_code=0)
×
87

88

UNCOV
89
def rules():
×
UNCOV
90
    return (*collect_rules(), UnionRule(ExportableTool, SuccinctCodeCounter))
×
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