mongo/buildscripts/linter/ruffchecker.py
Juan Gu 2513cc511b SERVER-94076 Remove unused imports via Ruff rule (#27337)
GitOrigin-RevId: 8923cc14f276be93355d763cb88c04bdb4dd9000
2024-10-04 01:43:13 +00:00

34 lines
870 B
Python

"""Ruff linter support module."""
from . import base
class RuffChecker(base.LinterBase):
"""Ruff linter."""
def __init__(self):
# type: () -> None
"""Create a Ruff linter."""
super(RuffChecker, self).__init__("ruff", "0.4.4")
def get_lint_version_cmd_args(self) -> list[str]:
"""Get the command to run a version check."""
return ["--version"]
def get_lint_cmd_args(self, files: list[str]) -> list[str]:
"""Get the command to run a check."""
if not files:
return ["check"]
files = " ".join(files)
return ["check", files]
def get_fix_cmd_args(self, files: list[str]) -> list[str]:
"""Get the command to run a fix."""
if not files:
return ["check", "--fix"]
files = " ".join(files)
return ["check", "--fix", files]