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

pantsbuild / pants / 21832085155

09 Feb 2026 03:53PM UTC coverage: 70.203% (-10.1%) from 80.282%
21832085155

push

github

web-flow
Prepare 2.30.2rc0 (#23079)

56068 of 79865 relevant lines covered (70.2%)

2.05 hits per line

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

0.0
/src/python/pants/backend/jsx/goals/tailor.py
1
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
×
5

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

10
from pants.backend.jsx.target_types import (
×
11
    JSX_FILE_EXTENSIONS,
12
    JSXSourcesGeneratorTarget,
13
    JSXTestsGeneratorSourcesField,
14
    JSXTestsGeneratorTarget,
15
)
16
from pants.core.goals.tailor import (
×
17
    AllOwnedSources,
18
    PutativeTarget,
19
    PutativeTargets,
20
    PutativeTargetsRequest,
21
)
22
from pants.core.util_rules.ownership import get_unowned_files_for_globs
×
23
from pants.core.util_rules.source_files import classify_files_for_sources_and_tests
×
24
from pants.engine.rules import Rule, collect_rules, rule
×
25
from pants.engine.unions import UnionRule
×
26
from pants.util.dirutil import group_by_dir
×
27
from pants.util.logging import LogLevel
×
28

29

30
@dataclass(frozen=True)
×
31
class PutativeJSXTargetsRequest(PutativeTargetsRequest):
×
32
    pass
×
33

34

35
@rule(level=LogLevel.DEBUG, desc="Determine candidate JSX targets to create")
×
36
async def find_putative_jsx_targets(
×
37
    req: PutativeJSXTargetsRequest, all_owned_sources: AllOwnedSources
38
) -> PutativeTargets:
39
    unowned_jsx_files = await get_unowned_files_for_globs(
×
40
        req, all_owned_sources, (f"*{ext}" for ext in JSX_FILE_EXTENSIONS)
41
    )
42
    classified_unowned_js_files = classify_files_for_sources_and_tests(
×
43
        paths=unowned_jsx_files,
44
        test_file_glob=JSXTestsGeneratorSourcesField.default,
45
        sources_generator=JSXSourcesGeneratorTarget,
46
        tests_generator=JSXTestsGeneratorTarget,
47
    )
48

49
    return PutativeTargets(
×
50
        PutativeTarget.for_target_type(
51
            tgt_type, path=dirname, name=name, triggering_sources=sorted(filenames)
52
        )
53
        for tgt_type, paths, name in (dataclasses.astuple(f) for f in classified_unowned_js_files)
54
        for dirname, filenames in group_by_dir(paths).items()
55
    )
56

57

58
def rules() -> Iterable[Rule | UnionRule]:
×
59
    return (
×
60
        *collect_rules(),
61
        UnionRule(PutativeTargetsRequest, PutativeJSXTargetsRequest),
62
    )
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