• 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/javascript/goals/tailor.py
1
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

UNCOV
4
from __future__ import annotations
×
5

UNCOV
6
import dataclasses
×
UNCOV
7
import os
×
UNCOV
8
from collections.abc import Iterable
×
UNCOV
9
from dataclasses import dataclass
×
10

UNCOV
11
from pants.backend.javascript.package_json import PackageJsonTarget
×
UNCOV
12
from pants.backend.javascript.target_types import (
×
13
    JS_FILE_EXTENSIONS,
14
    JSSourcesGeneratorTarget,
15
    JSTestsGeneratorSourcesField,
16
    JSTestsGeneratorTarget,
17
)
UNCOV
18
from pants.core.goals.tailor import (
×
19
    AllOwnedSources,
20
    PutativeTarget,
21
    PutativeTargets,
22
    PutativeTargetsRequest,
23
)
UNCOV
24
from pants.core.util_rules.ownership import get_unowned_files_for_globs
×
UNCOV
25
from pants.core.util_rules.source_files import classify_files_for_sources_and_tests
×
UNCOV
26
from pants.engine.rules import Rule, collect_rules, rule
×
UNCOV
27
from pants.engine.unions import UnionRule
×
UNCOV
28
from pants.util.dirutil import group_by_dir
×
UNCOV
29
from pants.util.logging import LogLevel
×
30

31

UNCOV
32
@dataclass(frozen=True)
×
UNCOV
33
class PutativeJSTargetsRequest(PutativeTargetsRequest):
×
UNCOV
34
    pass
×
35

36

UNCOV
37
@dataclass(frozen=True)
×
UNCOV
38
class PutativePackageJsonTargetsRequest(PutativeTargetsRequest):
×
UNCOV
39
    pass
×
40

41

UNCOV
42
_LOG_DESCRIPTION_TEMPLATE = "Determine candidate {} to create"
×
43

44

UNCOV
45
@rule(level=LogLevel.DEBUG, desc=_LOG_DESCRIPTION_TEMPLATE.format("JS targets"))
×
UNCOV
46
async def find_putative_js_targets(
×
47
    req: PutativeJSTargetsRequest, all_owned_sources: AllOwnedSources
48
) -> PutativeTargets:
49
    unowned_js_files = await get_unowned_files_for_globs(
×
50
        req, all_owned_sources, (f"*{ext}" for ext in JS_FILE_EXTENSIONS)
51
    )
52
    classified_unowned_js_files = classify_files_for_sources_and_tests(
×
53
        paths=unowned_js_files,
54
        test_file_glob=JSTestsGeneratorSourcesField.default,
55
        sources_generator=JSSourcesGeneratorTarget,
56
        tests_generator=JSTestsGeneratorTarget,
57
    )
58

59
    return PutativeTargets(
×
60
        PutativeTarget.for_target_type(
61
            tgt_type, path=dirname, name=name, triggering_sources=sorted(filenames)
62
        )
63
        for tgt_type, paths, name in (dataclasses.astuple(f) for f in classified_unowned_js_files)
64
        for dirname, filenames in group_by_dir(paths).items()
65
    )
66

67

UNCOV
68
@rule(level=LogLevel.DEBUG, desc=_LOG_DESCRIPTION_TEMPLATE.format("package.json targets"))
×
UNCOV
69
async def find_putative_package_json_targets(
×
70
    req: PutativePackageJsonTargetsRequest, all_owned_sources: AllOwnedSources
71
) -> PutativeTargets:
72
    unowned_package_json_files = await get_unowned_files_for_globs(
×
73
        req, all_owned_sources, (f"**{os.path.sep}package.json",)
74
    )
75

76
    putative_targets = [
×
77
        PutativeTarget.for_target_type(
78
            PackageJsonTarget, path=dirname, name=None, triggering_sources=[filename]
79
        )
80
        for dirname, filename in (os.path.split(file) for file in unowned_package_json_files)
81
    ]
82

83
    return PutativeTargets(putative_targets)
×
84

85

UNCOV
86
def rules() -> Iterable[Rule | UnionRule]:
×
UNCOV
87
    return (
×
88
        *collect_rules(),
89
        UnionRule(PutativeTargetsRequest, PutativeJSTargetsRequest),
90
        UnionRule(PutativeTargetsRequest, PutativePackageJsonTargetsRequest),
91
    )
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

© 2025 Coveralls, Inc