• 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/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

UNCOV
4
from __future__ import annotations
×
5

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

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

21

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

UNCOV
26
    source: SqlSourceField
×
27

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

32

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

38

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

43

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

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

UNCOV
52
    register_interpreter_constraints = True
×
UNCOV
53
    default_interpreter_constraints = ["CPython>=3.9,<3.14"]
×
54

UNCOV
55
    default_lockfile_resource = ("pants.backend.sql.lint.sqlfluff", "sqlfluff.lock")
×
56

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

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

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

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

103

UNCOV
104
def rules() -> Iterable[Rule]:
×
UNCOV
105
    return collect_rules()
×
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