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

pantsbuild / pants / 18252174847

05 Oct 2025 01:36AM UTC coverage: 43.382% (-36.9%) from 80.261%
18252174847

push

github

web-flow
run tests on mac arm (#22717)

Just doing the minimal to pull forward the x86_64 pattern.

ref #20993

25776 of 59416 relevant lines covered (43.38%)

1.3 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

4
from __future__ import annotations
×
5

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

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

27
logger = logging.getLogger(__name__)
×
28

29

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

34
    sources: JSRuntimeSourceField
×
35

36

37
class PrettierFmtRequest(FmtTargetsRequest):
×
38
    field_set_type = PrettierFmtFieldSet
×
39
    tool_subsystem = Prettier
×
40
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
×
41

42

43
@rule(level=LogLevel.DEBUG)
×
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

74
def rules() -> Iterable[Rule | UnionRule]:
×
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