Revert "SERVER-90583: Add Ruff to bazel //:format target (#22268)"

This reverts commit c7bf1f40180c861f4418898fd34aa1097438456c.

GitOrigin-RevId: 2e57b7804ad7b55034b8d19da29e93b989539dd6
This commit is contained in:
auto-revert-processor 2024-05-16 23:57:57 +00:00 committed by MongoDB Bot
parent b4b23946cd
commit 9cad6d1fb4
3 changed files with 7 additions and 42 deletions

View File

@ -149,12 +149,3 @@ npm_translate_lock(
load("@npm//:repositories.bzl", "npm_repositories")
npm_repositories()
ruff_version = "0.4.4"
http_archive(
name = "ruff-linux",
build_file_content = 'exports_files(["ruff"])',
sha256 = "8ae35b6773bba1ca414c5134ba7e10935f35880bebbe50f18bb609bad9da5b13",
urls = ["https://github.com/astral-sh/ruff/releases/download/v{0}/ruff-{0}-aarch64-unknown-linux-gnu.tar.gz".format(ruff_version)],
)

View File

@ -11,24 +11,14 @@ prettier.prettier_binary(
env = {"BAZEL_BINDIR": "."},
)
alias(
name = "ruff",
actual = "@ruff-linux//:ruff",
)
py_binary(
name = "format",
srcs = ["format.py"],
args = [
"--prettier",
"$(location :prettier)",
"--ruff",
"$(location :ruff)",
],
data = [
":prettier",
":ruff",
],
data = [":prettier"],
main = "format.py",
visibility = ["//visibility:public"],
)

View File

@ -5,20 +5,12 @@ import subprocess
def run_prettier(prettier: pathlib.Path, check: bool) -> int:
command = [prettier, ".", "--check" if check else "--write"]
cmd_status = run_formatter(command, check)
return cmd_status
def run_ruff(ruff: pathlib.Path, check: bool) -> int:
command = [ruff, "format"]
if check:
command.append("--check")
cmd_status = run_formatter(command, check)
return cmd_status
def run_formatter(command: str, check: bool) -> int:
try:
command = [prettier, "."]
if check:
command.append("--check")
else:
command.append("--write")
print(f"Running command: '{command}'")
subprocess.run(command, check=True)
except subprocess.CalledProcessError:
@ -45,22 +37,14 @@ def main() -> int:
description='This script formats code in mongodb')
parser.add_argument("--check", help="Run in check mode", default=False, action="store_true")
parser.add_argument("--ruff", help="Set the path to ruff", required=True,
type=pathlib.Path)
parser.add_argument("--prettier", help="Set the path to prettier", required=True,
type=pathlib.Path)
args = parser.parse_args()
prettier_path: pathlib.Path = args.prettier.resolve()
ruff_path: pathlib.Path = args.ruff.resolve()
os.chdir(default_dir)
status = 0
status |= run_ruff(ruff_path, args.check)
status |= run_prettier(prettier_path, args.check)
return status
return run_prettier(prettier_path, args.check)
if __name__ == "__main__":