• 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/isort/subsystem.py
1
# Copyright 2018 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, FileListOption, SkipOption
×
UNCOV
16
from pants.util.strutil import softwrap
×
17

18

UNCOV
19
class Isort(PythonToolBase):
×
UNCOV
20
    options_scope = "isort"
×
UNCOV
21
    name = "isort"
×
UNCOV
22
    help_short = "The Python import sorter tool (https://pycqa.github.io/isort/)."
×
23

UNCOV
24
    default_main = ConsoleScript("isort")
×
UNCOV
25
    default_requirements = ["isort[pyproject,colors]>=5.9.3,<6.0"]
×
26

UNCOV
27
    register_interpreter_constraints = True
×
28

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

UNCOV
31
    skip = SkipOption("fmt", "lint")
×
UNCOV
32
    args = ArgsListOption(example="--case-sensitive --trailing-comma")
×
UNCOV
33
    config = FileListOption(
×
34
        # TODO: Figure out how to deprecate this being a list in favor of a single string.
35
        #  Thanks to config autodiscovery, this option should only be used because you want
36
        #  Pants to explicitly set `--settings`, which only works w/ 1 config file.
37
        #  isort 4 users should instead use autodiscovery to support multiple config files.
38
        #  Deprecating this could be tricky, but should be possible thanks to the implicit
39
        #  add syntax.
40
        #
41
        #  When deprecating, also deprecate the user manually setting `--settings` with
42
        #  `[isort].args`.
43
        advanced=True,
44
        help=lambda cls: softwrap(
45
            f"""
46
            Path to config file understood by isort
47
            (https://pycqa.github.io/isort/docs/configuration/config_files/).
48

49
            Setting this option will disable `[{cls.options_scope}].config_discovery`. Use
50
            this option if the config is located in a non-standard location.
51

52
            If using isort 5+ and you specify only 1 config file, Pants will configure
53
            isort's argv to point to your config file.
54
            """
55
        ),
56
    )
UNCOV
57
    config_discovery = BoolOption(
×
58
        default=True,
59
        advanced=True,
60
        help=lambda cls: softwrap(
61
            f"""
62
            If true, Pants will include any relevant config files during
63
            runs (`.isort.cfg`, `pyproject.toml`, `setup.cfg`, `tox.ini` and `.editorconfig`).
64

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

UNCOV
71
    def config_request(self, dirs: Iterable[str]) -> ConfigFilesRequest:
×
72
        # Refer to https://pycqa.github.io/isort/docs/configuration/config_files/.
73
        check_existence = []
×
74
        check_content = {}
×
75
        for d in ("", *dirs):
×
76
            check_existence.append(os.path.join(d, ".isort.cfg"))
×
77
            check_content.update(
×
78
                {
79
                    os.path.join(d, "pyproject.toml"): b"[tool.isort]",
80
                    os.path.join(d, "setup.cfg"): b"[isort]",
81
                    os.path.join(d, "tox.ini"): b"[isort]",
82
                    os.path.join(d, ".editorconfig"): b"[*.py]",
83
                }
84
            )
85

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

94

UNCOV
95
def rules():
×
UNCOV
96
    return [
×
97
        *collect_rules(),
98
        UnionRule(ExportableTool, Isort),
99
    ]
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