Skip to content

Commit

Permalink
build: adds a reformat-py command to run ruff to reformat the python …
Browse files Browse the repository at this point in the history
…files
  • Loading branch information
jgpruitt committed Jan 16, 2025
1 parent baf12ff commit 90e07b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions projects/extension/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 .""",
Expand Down Expand Up @@ -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":
Expand Down
3 changes: 3 additions & 0 deletions projects/extension/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 90e07b1

Please sign in to comment.