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

UNCOV
4
from dataclasses import dataclass
×
5

UNCOV
6
from pants.backend.python.lint.docformatter.skip_field import SkipDocformatterField
×
UNCOV
7
from pants.backend.python.lint.docformatter.subsystem import Docformatter
×
UNCOV
8
from pants.backend.python.target_types import PythonSourceField
×
UNCOV
9
from pants.backend.python.util_rules import pex
×
UNCOV
10
from pants.backend.python.util_rules.pex import VenvPexProcess, create_venv_pex
×
UNCOV
11
from pants.core.goals.fmt import FmtResult, FmtTargetsRequest
×
UNCOV
12
from pants.core.util_rules.partitions import PartitionerType
×
UNCOV
13
from pants.engine.intrinsics import execute_process
×
UNCOV
14
from pants.engine.process import ProcessExecutionFailure
×
UNCOV
15
from pants.engine.rules import collect_rules, implicitly, rule
×
UNCOV
16
from pants.engine.target import FieldSet, Target
×
UNCOV
17
from pants.option.global_options import KeepSandboxes
×
UNCOV
18
from pants.util.logging import LogLevel
×
UNCOV
19
from pants.util.strutil import pluralize
×
20

21

UNCOV
22
@dataclass(frozen=True)
×
UNCOV
23
class DocformatterFieldSet(FieldSet):
×
UNCOV
24
    required_fields = (PythonSourceField,)
×
25

26
    source: PythonSourceField
27

UNCOV
28
    @classmethod
×
UNCOV
29
    def opt_out(cls, tgt: Target) -> bool:
×
30
        return tgt.get(SkipDocformatterField).value
×
31

32

UNCOV
33
class DocformatterRequest(FmtTargetsRequest):
×
UNCOV
34
    field_set_type = DocformatterFieldSet
×
UNCOV
35
    tool_subsystem = Docformatter  # type: ignore[assignment]
×
UNCOV
36
    partitioner_type = PartitionerType.DEFAULT_SINGLE_PARTITION
×
37

38

UNCOV
39
@rule(desc="Format with docformatter", level=LogLevel.DEBUG)
×
UNCOV
40
async def docformatter_fmt(
×
41
    request: DocformatterRequest.Batch, docformatter: Docformatter, keep_sandboxes: KeepSandboxes
42
) -> FmtResult:
43
    docformatter_pex = await create_venv_pex(**implicitly(docformatter.to_pex_request()))
×
44
    description = f"Run Docformatter on {pluralize(len(request.files), 'file')}."
×
45
    result = await execute_process(
×
46
        **implicitly(
47
            VenvPexProcess(
48
                docformatter_pex,
49
                argv=(
50
                    "--in-place",
51
                    *docformatter.args,
52
                    *request.files,
53
                ),
54
                input_digest=request.snapshot.digest,
55
                output_files=request.files,
56
                description=description,
57
                level=LogLevel.DEBUG,
58
            )
59
        )
60
    )
61
    # Docformatter 1.6.0+ very annoyingly returns an exit code of 3 if run with `--in-place`
62
    # and any files changed. Earlier versions do not return this code in fmt mode.
63
    # (All versions return 3 in check mode if any files would have changed, but that is
64
    # not an issue here).
65
    if result.exit_code not in [0, 3]:
×
66
        # TODO(#12725):It would be more straightforward to force the exception with:
67
        # result = await fallible_to_exec_result_or_raise(result, **implicitly())
68
        raise ProcessExecutionFailure(
×
69
            result.exit_code,
70
            result.stdout,
71
            result.stderr,
72
            description,
73
            keep_sandboxes=keep_sandboxes,
74
        )
75

76
    return await FmtResult.create(request, result)
×
77

78

UNCOV
79
def rules():
×
UNCOV
80
    return (
×
81
        *collect_rules(),
82
        *DocformatterRequest.rules(),
83
        *pex.rules(),
84
    )
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