• 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/python/lint/yapf/rules.py
1
# Copyright 2021 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
from dataclasses import dataclass
×
7

UNCOV
8
from pants.backend.python.lint.yapf.skip_field import SkipYapfField
×
UNCOV
9
from pants.backend.python.lint.yapf.subsystem import Yapf
×
UNCOV
10
from pants.backend.python.target_types import PythonSourceField
×
UNCOV
11
from pants.backend.python.util_rules import pex
×
UNCOV
12
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
×
UNCOV
13
from pants.backend.python.util_rules.pex import VenvPexProcess, create_venv_pex
×
UNCOV
14
from pants.core.goals.fmt import AbstractFmtRequest, FmtResult, FmtTargetsRequest
×
UNCOV
15
from pants.core.util_rules.config_files import find_config_file
×
UNCOV
16
from pants.core.util_rules.partitions import PartitionerType
×
UNCOV
17
from pants.engine.fs import MergeDigests
×
UNCOV
18
from pants.engine.intrinsics import merge_digests
×
UNCOV
19
from pants.engine.process import execute_process_or_raise
×
UNCOV
20
from pants.engine.rules import collect_rules, concurrently, implicitly, rule
×
UNCOV
21
from pants.engine.target import FieldSet, Target
×
UNCOV
22
from pants.util.logging import LogLevel
×
UNCOV
23
from pants.util.strutil import pluralize
×
24

25

UNCOV
26
@dataclass(frozen=True)
×
UNCOV
27
class YapfFieldSet(FieldSet):
×
UNCOV
28
    required_fields = (PythonSourceField,)
×
29

UNCOV
30
    source: PythonSourceField
×
31

UNCOV
32
    @classmethod
×
UNCOV
33
    def opt_out(cls, tgt: Target) -> bool:
×
34
        return tgt.get(SkipYapfField).value
×
35

36

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

42

UNCOV
43
async def _run_yapf(
×
44
    request: AbstractFmtRequest.Batch,
45
    yapf: Yapf,
46
    interpreter_constraints: InterpreterConstraints | None = None,
47
) -> FmtResult:
48
    yapf_pex_get = create_venv_pex(
×
49
        **implicitly(yapf.to_pex_request(interpreter_constraints=interpreter_constraints))
50
    )
51
    config_files_get = find_config_file(yapf.config_request(request.snapshot.dirs))
×
52
    yapf_pex, config_files = await concurrently(yapf_pex_get, config_files_get)
×
53

54
    input_digest = await merge_digests(
×
55
        MergeDigests((request.snapshot.digest, config_files.snapshot.digest))
56
    )
57
    result = await execute_process_or_raise(
×
58
        **implicitly(
59
            VenvPexProcess(
60
                yapf_pex,
61
                argv=(
62
                    *yapf.args,
63
                    "--in-place",
64
                    *(("--style", yapf.config) if yapf.config else ()),
65
                    *request.files,
66
                ),
67
                input_digest=input_digest,
68
                output_files=request.files,
69
                description=f"Run yapf on {pluralize(len(request.files), 'file')}.",
70
                level=LogLevel.DEBUG,
71
            )
72
        )
73
    )
74
    return await FmtResult.create(request, result)
×
75

76

UNCOV
77
@rule(desc="Format with yapf", level=LogLevel.DEBUG)
×
UNCOV
78
async def yapf_fmt(request: YapfRequest.Batch, yapf: Yapf) -> FmtResult:
×
79
    return await _run_yapf(request, yapf)
×
80

81

UNCOV
82
def rules():
×
UNCOV
83
    return (
×
84
        *collect_rules(),
85
        *YapfRequest.rules(),
86
        *pex.rules(),
87
    )
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