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

pantsbuild / pants / 19477274756

18 Nov 2025 06:38PM UTC coverage: 80.291% (+0.001%) from 80.29%
19477274756

Pull #22889

github

web-flow
Merge f14bb9a80 into a217a6c34
Pull Request #22889: Java fix bug with inner class inference

21 of 27 new or added lines in 2 files covered. (77.78%)

267 existing lines in 10 files now uncovered.

78098 of 97269 relevant lines covered (80.29%)

3.36 hits per line

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

95.35
/src/python/pants/backend/sql/lint/sqlfluff/subsystem.py
1
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
3✔
5

6
import os.path
3✔
7
from collections.abc import Iterable
3✔
8
from dataclasses import dataclass
3✔
9
from enum import Enum
3✔
10

11
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
3✔
12
from pants.backend.python.target_types import ConsoleScript
3✔
13
from pants.backend.sql.lint.sqlfluff.skip_field import SkipSqlfluffField
3✔
14
from pants.backend.sql.target_types import SqlSourceField
3✔
15
from pants.core.util_rules.config_files import ConfigFilesRequest
3✔
16
from pants.engine.rules import Rule, collect_rules
3✔
17
from pants.engine.target import FieldSet, Target
3✔
18
from pants.option.option_types import ArgsListOption, BoolOption, FileOption, SkipOption
3✔
19
from pants.util.strutil import softwrap
3✔
20

21

22
@dataclass(frozen=True)
3✔
23
class SqlfluffFieldSet(FieldSet):
3✔
24
    required_fields = (SqlSourceField,)
3✔
25

26
    source: SqlSourceField
3✔
27

28
    @classmethod
3✔
29
    def opt_out(cls, tgt: Target) -> bool:
3✔
30
        return tgt.get(SkipSqlfluffField).value
3✔
31

32

33
class SqlfluffMode(str, Enum):
3✔
34
    LINT = "lint"
3✔
35
    FIX = "fix"
3✔
36
    FMT = "format"
3✔
37

38

39
# --------------------------------------------------------------------------------------
40
# Subsystem
41
# --------------------------------------------------------------------------------------
42

43

44
class Sqlfluff(PythonToolBase):
3✔
45
    options_scope = "sqlfluff"
3✔
46
    name = "Sqlfluff"
3✔
47
    help_short = "The Sqlfluff SQL linter (https://github.com/sqlfluff/sqlfluff)."
3✔
48

49
    default_main = ConsoleScript("sqlfluff")
3✔
50
    default_requirements = ["sqlfluff>=2.3.5,<3"]
3✔
51

52
    register_interpreter_constraints = True
3✔
53

54
    default_lockfile_resource = ("pants.backend.sql.lint.sqlfluff", "sqlfluff.lock")
3✔
55

56
    skip = SkipOption("fmt", "fix", "lint")
3✔
57
    args = ArgsListOption(example="--dialect=postgres --exclude-rules LT08,RF02")
3✔
58
    fix_args = ArgsListOption(example="--force")
3✔
59
    config = FileOption(
3✔
60
        default=None,
61
        advanced=True,
62
        help=softwrap(
63
            f"""
64
            Path to the `pyproject.toml` or `.sqlfluff` file to use for configuration
65
            (https://docs.sqlfluff.com/en/stable/configuration.html).
66

67
            Setting this option will disable `[{options_scope}].config_discovery`. Use
68
            this option if the config is located in a non-standard location.
69
            """
70
        ),
71
    )
72
    config_discovery = BoolOption(
3✔
73
        default=True,
74
        advanced=True,
75
        help=softwrap(
76
            f"""
77
            If true, Pants will include any relevant config files during
78
            runs (`pyproject.toml`, and `.sqlfluff`).
79

80
            Use `[{options_scope}].config` instead if your config is in a
81
            non-standard location.
82
            """
83
        ),
84
    )
85

86
    def config_request(self, dirs: Iterable[str]) -> ConfigFilesRequest:
3✔
87
        # See https://docs.sqlfluff.com/en/stable/configuration.html for how
88
        # sqlfluff discovers config files.
UNCOV
89
        all_dirs = ("", *dirs)
×
90
        return ConfigFilesRequest(
×
91
            specified=self.config,
92
            specified_option_name=f"[{self.options_scope}].config",
93
            discovery=self.config_discovery,
94
            check_existence=[
95
                os.path.join(d, filename)
96
                for d in all_dirs
97
                for filename in ["setup.cfg", "tox.ini", "pep8.ini", ".sqlfluff"]
98
            ],
99
            check_content={os.path.join(d, "pyproject.toml"): b"[tool.sqlfluff" for d in all_dirs},
100
        )
101

102

103
def rules() -> Iterable[Rule]:
3✔
104
    return collect_rules()
3✔
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