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

pantsbuild / pants / 20830576679

08 Jan 2026 08:22PM UTC coverage: 80.266% (-0.008%) from 80.274%
20830576679

Pull #22989

github

web-flow
Merge 60b650c99 into 0d471f924
Pull Request #22989: add a backend for running codespell a linter

152 of 192 new or added lines in 3 files covered. (79.17%)

6 existing lines in 2 files now uncovered.

78941 of 98349 relevant lines covered (80.27%)

3.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.3
/src/python/pants/backend/tools/codespell/subsystem.py
1
# Copyright 2026 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
1✔
5

6
from typing import Iterable
1✔
7

8
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
1✔
9
from pants.backend.python.target_types import ConsoleScript
1✔
10
from pants.core.goals.resolves import ExportableTool
1✔
11
from pants.core.util_rules.config_files import OrphanFilepathConfigBehavior
1✔
12
from pants.engine.rules import Rule, collect_rules
1✔
13
from pants.engine.unions import UnionRule
1✔
14
from pants.option.option_types import (
1✔
15
    ArgsListOption,
16
    EnumOption,
17
    SkipOption,
18
    StrListOption,
19
    StrOption,
20
)
21
from pants.util.strutil import softwrap
1✔
22

23

24
class Codespell(PythonToolBase):
1✔
25
    name = "Codespell"
1✔
26
    options_scope = "codespell"
1✔
27
    help_short = "A tool to find common misspellings in text files (https://github.com/codespell-project/codespell)"
1✔
28

29
    default_main = ConsoleScript("codespell")
1✔
30
    default_requirements = ["codespell>=2.2.6,<3", "tomli>=1.1.0; python_version < '3.11'"]
1✔
31

32
    register_interpreter_constraints = True
1✔
33

34
    register_lockfile = True
1✔
35
    default_lockfile_resource = ("pants.backend.tools.codespell", "codespell.lock")
1✔
36

37
    skip = SkipOption("lint")
1✔
38

39
    args = ArgsListOption(example="--quiet-level=2 --ignore-words-list=word1,word2")
1✔
40

41
    config_file_name = StrOption(
1✔
42
        "--config-file-name",
43
        default=".codespellrc",
44
        advanced=True,
45
        help=softwrap(
46
            """
47
            Name of a config file understood by codespell
48
            (https://github.com/codespell-project/codespell#using-a-config-file).
49
            The plugin will search the ancestors of each directory in which files are found
50
            for a config file of this name.
51
            """
52
        ),
53
    )
54

55
    orphan_files_behavior = EnumOption(
1✔
56
        default=OrphanFilepathConfigBehavior.IGNORE,
57
        advanced=True,
58
        help=softwrap(
59
            f"""
60
            Whether to ignore, error or show a warning when files are found that are not
61
            covered by the config file provided in `[{options_scope}].config_file_name` setting.
62
            """
63
        ),
64
    )
65

66
    file_glob_include = StrListOption(
1✔
67
        "--include",
68
        default=["**/*"],
69
        help="Glob patterns for files to check with codespell.",
70
    )
71

72
    file_glob_exclude = StrListOption(
1✔
73
        "--exclude",
74
        default=[],
75
        help="Glob patterns for files to exclude from codespell checks.",
76
    )
77

78

79
def rules() -> Iterable[Rule | UnionRule]:
1✔
NEW
80
    return [
×
81
        *collect_rules(),
82
        UnionRule(ExportableTool, Codespell),
83
    ]
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

© 2026 Coveralls, Inc