From 90e07b1ab45275215a69e7c190a23d08f1482666 Mon Sep 17 00:00:00 2001 From: John Pruitt Date: Wed, 15 Jan 2025 12:33:45 -0600 Subject: [PATCH] build: adds a reformat-py command to run ruff to reformat the python files --- projects/extension/build.py | 7 +++++++ projects/extension/justfile | 3 +++ 2 files changed, 10 insertions(+) diff --git a/projects/extension/build.py b/projects/extension/build.py index 58f87b20..d863d7f1 100755 --- a/projects/extension/build.py +++ b/projects/extension/build.py @@ -34,6 +34,7 @@ - lint-py runs ruff linter against the python source files - lint runs both sql and python linters - format-py runs ruff to check formatting of the python source files +- reformat-py runs ruff to update the formatting of the python source files - docker-build builds the dev docker image - docker-run launches a container in docker using the docker image - docker-stop stops the container @@ -696,6 +697,10 @@ def format_py() -> None: ) +def reformat_py() -> None: + subprocess.run(f"ruff format {ext_dir()}", shell=True, check=True, env=os.environ) + + def docker_build() -> None: subprocess.run( f"""docker build --build-arg PG_MAJOR={pg_major()} -t pgai-ext .""", @@ -805,6 +810,8 @@ def run() -> None: lint() elif action == "format-py": format_py() + elif action == "reformat-py": + reformat_py() elif action == "docker-build": docker_build() elif action == "docker-run": diff --git a/projects/extension/justfile b/projects/extension/justfile index e8a465f1..ffef66c7 100644 --- a/projects/extension/justfile +++ b/projects/extension/justfile @@ -83,6 +83,9 @@ lint: format-py: @./build.py format-py +reformat-py: + @./build.py reformat-py + docker-build: @PG_MAJOR={{PG_MAJOR}} ./build.py docker-build