• 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/lint/prettier/rules.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 logging
×
UNCOV
7
import os
×
UNCOV
8
from collections.abc import Iterable
×
UNCOV
9
from dataclasses import dataclass
×
10

UNCOV
11
from pants.backend.javascript.lint.prettier.subsystem import Prettier
×
UNCOV
12
from pants.backend.javascript.subsystems import nodejs_tool
×
UNCOV
13
from pants.backend.javascript.subsystems.nodejs_tool import NodeJSToolRequest
×
UNCOV
14
from pants.backend.javascript.target_types import JSRuntimeSourceField
×
UNCOV
15
from pants.core.goals.fmt import FmtResult, FmtTargetsRequest
×
UNCOV
16
from pants.core.util_rules.config_files import find_config_file
×
UNCOV
17
from pants.core.util_rules.partitions import PartitionerType
×
UNCOV
18
from pants.engine.fs import MergeDigests
×
UNCOV
19
from pants.engine.intrinsics import merge_digests
×
UNCOV
20
from pants.engine.process import execute_process_or_raise
×
UNCOV
21
from pants.engine.rules import Rule, collect_rules, implicitly, rule
×
UNCOV
22
from pants.engine.target import FieldSet
×
UNCOV
23
from pants.engine.unions import UnionRule
×
UNCOV
24
from pants.util.logging import LogLevel
×
UNCOV
25
from pants.util.strutil import pluralize
×
26

UNCOV
27
logger = logging.getLogger(__name__)
×
28

29

UNCOV
30
@dataclass(frozen=True)
×
UNCOV
31
class PrettierFmtFieldSet(FieldSet):
×
UNCOV
32
    required_fields = (JSRuntimeSourceField,)
×
33

UNCOV
34
    sources: JSRuntimeSourceField
×
35

36

UNCOV
37
class PrettierFmtRequest(FmtTargetsRequest):
×
UNCOV
38
    field_set_type = PrettierFmtFieldSet
×
UNCOV
39
    tool_subsystem = Prettier  # type: ignore[assignment]
×
UNCOV
40
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
×
41

42

UNCOV
43
@rule(level=LogLevel.DEBUG)
×
UNCOV
44
async def prettier_fmt(request: PrettierFmtRequest.Batch, prettier: Prettier) -> FmtResult:
×
45
    # Look for any/all of the Prettier configuration files
46
    config_files = await find_config_file(prettier.config_request(request.snapshot.dirs))
×
47

48
    # Merge source files, config files, and prettier_tool process
49
    input_digest = await merge_digests(
×
50
        MergeDigests(
51
            (
52
                request.snapshot.digest,
53
                config_files.snapshot.digest,
54
            )
55
        )
56
    )
57

58
    result = await execute_process_or_raise(
×
59
        **implicitly(
60
            {
61
                prettier.request(
62
                    args=("--write", *(os.path.join("{chroot}", file) for file in request.files)),
63
                    input_digest=input_digest,
64
                    output_files=request.files,
65
                    description=f"Run Prettier on {pluralize(len(request.files), 'file')}.",
66
                    level=LogLevel.DEBUG,
67
                ): NodeJSToolRequest
68
            }
69
        )
70
    )
71
    return await FmtResult.create(request, result)
×
72

73

UNCOV
74
def rules() -> Iterable[Rule | UnionRule]:
×
UNCOV
75
    return (
×
76
        *collect_rules(),
77
        *nodejs_tool.rules(),
78
        *PrettierFmtRequest.rules(),
79
    )
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