• 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/subsystem.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
import os.path
×
UNCOV
7
from collections.abc import Iterable
×
8

UNCOV
9
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
×
UNCOV
10
from pants.backend.python.target_types import ConsoleScript
×
UNCOV
11
from pants.core.goals.resolves import ExportableTool
×
UNCOV
12
from pants.core.util_rules.config_files import ConfigFilesRequest
×
UNCOV
13
from pants.engine.rules import collect_rules
×
UNCOV
14
from pants.engine.unions import UnionRule
×
UNCOV
15
from pants.option.option_types import ArgsListOption, BoolOption, FileOption, SkipOption
×
UNCOV
16
from pants.util.strutil import softwrap
×
17

18

UNCOV
19
class Yapf(PythonToolBase):
×
UNCOV
20
    options_scope = "yapf"
×
UNCOV
21
    name = "yapf"
×
UNCOV
22
    help_short = "A formatter for Python files (https://github.com/google/yapf)."
×
23

UNCOV
24
    default_main = ConsoleScript("yapf")
×
UNCOV
25
    default_requirements = ["yapf>=0.32.0,<1", "toml"]
×
26

UNCOV
27
    register_interpreter_constraints = True
×
28

UNCOV
29
    default_lockfile_resource = ("pants.backend.python.lint.yapf", "yapf.lock")
×
30

UNCOV
31
    skip = SkipOption("fmt", "lint")
×
UNCOV
32
    args = ArgsListOption(
×
33
        example="--no-local-style",
34
        extra_help=softwrap(
35
            """
36
            Certain arguments, specifically `--recursive`, `--in-place`, and
37
            `--parallel`, will be ignored because Pants takes care of finding
38
            all the relevant files and running the formatting in parallel.
39
            """
40
        ),
41
    )
UNCOV
42
    config = FileOption(
×
43
        default=None,
44
        advanced=True,
45
        help=lambda cls: softwrap(
46
            f"""
47
            Path to style file understood by yapf
48
            (https://github.com/google/yapf#formatting-style/).
49

50
            Setting this option will disable `[{cls.options_scope}].config_discovery`. Use
51
            this option if the config is located in a non-standard location.
52
            """
53
        ),
54
    )
UNCOV
55
    config_discovery = BoolOption(
×
56
        default=True,
57
        advanced=True,
58
        help=lambda cls: softwrap(
59
            f"""
60
            If true, Pants will include any relevant config files during
61
            runs (`.style.yapf`, `pyproject.toml`, and `setup.cfg`).
62

63
            Use `[{cls.options_scope}].config` instead if your config is in a
64
            non-standard location.
65
            """
66
        ),
67
    )
68

UNCOV
69
    def config_request(self, dirs: Iterable[str]) -> ConfigFilesRequest:
×
70
        # Refer to https://github.com/google/yapf#formatting-style.
71
        check_existence = []
×
72
        check_content = {}
×
73
        for d in ("", *dirs):
×
74
            check_existence.append(os.path.join(d, ".yapfignore"))
×
75
            check_content.update(
×
76
                {
77
                    os.path.join(d, "pyproject.toml"): b"[tool.yapf",
78
                    os.path.join(d, "setup.cfg"): b"[yapf]",
79
                    os.path.join(d, ".style.yapf"): b"[style]",
80
                }
81
            )
82

83
        return ConfigFilesRequest(
×
84
            specified=self.config,
85
            specified_option_name=f"[{self.options_scope}].config",
86
            discovery=self.config_discovery,
87
            check_existence=check_existence,
88
            check_content=check_content,
89
        )
90

91

UNCOV
92
def rules():
×
UNCOV
93
    return [
×
94
        *collect_rules(),
95
        UnionRule(ExportableTool, Yapf),
96
    ]
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