mirror of https://github.com/mongodb/mongo
Revert "SERVER-90583: Add Ruff to bazel //:format target (#22268)"
This reverts commit c7bf1f40180c861f4418898fd34aa1097438456c. GitOrigin-RevId: 2e57b7804ad7b55034b8d19da29e93b989539dd6
This commit is contained in:
parent
b4b23946cd
commit
9cad6d1fb4
|
|
@ -149,12 +149,3 @@ npm_translate_lock(
|
||||||
load("@npm//:repositories.bzl", "npm_repositories")
|
load("@npm//:repositories.bzl", "npm_repositories")
|
||||||
|
|
||||||
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)],
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -11,24 +11,14 @@ prettier.prettier_binary(
|
||||||
env = {"BAZEL_BINDIR": "."},
|
env = {"BAZEL_BINDIR": "."},
|
||||||
)
|
)
|
||||||
|
|
||||||
alias(
|
|
||||||
name = "ruff",
|
|
||||||
actual = "@ruff-linux//:ruff",
|
|
||||||
)
|
|
||||||
|
|
||||||
py_binary(
|
py_binary(
|
||||||
name = "format",
|
name = "format",
|
||||||
srcs = ["format.py"],
|
srcs = ["format.py"],
|
||||||
args = [
|
args = [
|
||||||
"--prettier",
|
"--prettier",
|
||||||
"$(location :prettier)",
|
"$(location :prettier)",
|
||||||
"--ruff",
|
|
||||||
"$(location :ruff)",
|
|
||||||
],
|
|
||||||
data = [
|
|
||||||
":prettier",
|
|
||||||
":ruff",
|
|
||||||
],
|
],
|
||||||
|
data = [":prettier"],
|
||||||
main = "format.py",
|
main = "format.py",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,12 @@ import subprocess
|
||||||
|
|
||||||
|
|
||||||
def run_prettier(prettier: pathlib.Path, check: bool) -> int:
|
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:
|
try:
|
||||||
|
command = [prettier, "."]
|
||||||
|
if check:
|
||||||
|
command.append("--check")
|
||||||
|
else:
|
||||||
|
command.append("--write")
|
||||||
print(f"Running command: '{command}'")
|
print(f"Running command: '{command}'")
|
||||||
subprocess.run(command, check=True)
|
subprocess.run(command, check=True)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
|
@ -45,22 +37,14 @@ def main() -> int:
|
||||||
description='This script formats code in mongodb')
|
description='This script formats code in mongodb')
|
||||||
|
|
||||||
parser.add_argument("--check", help="Run in check mode", default=False, action="store_true")
|
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,
|
parser.add_argument("--prettier", help="Set the path to prettier", required=True,
|
||||||
type=pathlib.Path)
|
type=pathlib.Path)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
prettier_path: pathlib.Path = args.prettier.resolve()
|
prettier_path: pathlib.Path = args.prettier.resolve()
|
||||||
ruff_path: pathlib.Path = args.ruff.resolve()
|
|
||||||
|
|
||||||
os.chdir(default_dir)
|
os.chdir(default_dir)
|
||||||
|
return run_prettier(prettier_path, args.check)
|
||||||
status = 0
|
|
||||||
status |= run_ruff(ruff_path, args.check)
|
|
||||||
status |= run_prettier(prettier_path, args.check)
|
|
||||||
|
|
||||||
return status
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue