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

32 lines
863 B
Python

"""Ruff formatter support module."""
from . import base
class RuffFormatter(base.LinterBase):
"""Ruff formatter."""
def __init__(self):
"""Create a Ruff formatter."""
super(RuffFormatter, 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 ["format", "--check"]
files = " ".join(files)
return ["format", "--check", files]
def get_fix_cmd_args(self, files: list[str]) -> list[str]:
"""Get the command to run a fix."""
if not files:
return ["format"]
files = " ".join(files)
return ["format", files]