Skip to content

Commit

Permalink
Use the new hatch fmt command to run linters and formatting
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
negz committed Oct 10, 2024
1 parent d10f084 commit 7990ab8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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/*"]
Expand Down

0 comments on commit 7990ab8

Please sign in to comment.