Use the new hatch fmt command to run linters and formatting

Right now this defaults to a pretty old version of ruff. Hatch pins a
ruff version though, so I'm inclined to just use whatever ruff version
Hatch uses.

Signed-off-by: Nic Cope <nicc@rk0n.org>
This commit is contained in:
Nic Cope 2024-10-09 18:10:13 -07:00
parent d10f084b84
commit 7990ab8939
3 changed files with 8 additions and 12 deletions

View File

@ -49,7 +49,7 @@ jobs:
run: pipx install hatch==${{ env.HATCH_VERSION }}
- name: Lint
run: hatch run lint:check
run: hatch fmt
unit-test:
runs-on: ubuntu-22.04

View File

@ -34,8 +34,8 @@ Some useful commands:
# Generate gRPC stubs.
hatch run generate:protoc
# Lint the code.
hatch run lint:check
# Format and lint the code.
hatch fmt
# Run unit tests.
hatch test

View File

@ -49,15 +49,6 @@ dependencies = ["grpcio-tools==1.66.2"]
[tool.hatch.envs.generate.scripts]
protoc = "python -m grpc_tools.protoc --proto_path=. --python_out=. --pyi_out=. --grpc_python_out=. crossplane/function/proto/v1beta1/run_function.proto crossplane/function/proto/v1/run_function.proto"
[tool.hatch.envs.lint]
type = "virtual"
detached = true
path = ".venv-lint"
dependencies = ["ruff==0.6.9"]
[tool.hatch.envs.lint.scripts]
check = "ruff format crossplane tests && ruff check --fix crossplane tests"
[tool.hatch.envs.docs]
type = "virtual"
path = ".venv-docs"
@ -69,6 +60,11 @@ generate = "pdoc -m google crossplane/function -o docs"
[tool.hatch.build.targets.wheel]
packages = ["crossplane"]
# This special environment is used by hatch fmt.
[tool.hatch.envs.hatch-static-analysis]
dependencies = ["ruff==0.6.9"]
config-path = "none" # Disable Hatch's default Ruff config.
[tool.ruff]
target-version = "py311"
exclude = ["crossplane/function/proto/*", "tests/testdata/*"]