From 5a324c7638c86e6e1911627626c4de345c2cf4ab Mon Sep 17 00:00:00 2001 From: Henri Rosten Date: Fri, 3 Jan 2025 13:38:07 +0200 Subject: [PATCH] Use ruff python linter Signed-off-by: Henri Rosten --- Makefile | 9 +-------- nix/checks.nix | 10 ---------- nix/devshell.nix | 2 +- nix/treefmt.nix | 3 ++- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 70bbc3b..1a531bc 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ TARGET: ## DESCRIPTION help: ## Show this help message @grep -E '^[a-zA-Z_-]+:.*?##.*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' -pre-push: test format check ## Run tests and flake checks +pre-push: test check ## Run tests and flake checks $(call target_success,$@) test-ci: check ## Run CI tests @@ -31,13 +31,6 @@ test: ## Run tests pytest -vx tests/ $(call target_success,$@) -format: clean ## Reformat with black - @for py in $(PYTHON_TARGETS); \ - do echo "$$py:"; \ - black -q $$py; \ - done - $(call target_success,$@) - release-asset: clean ## Build release asset mkdir -p build/ nix run --extra-experimental-features 'flakes nix-command' .#sbomnix -- . \ diff --git a/nix/checks.nix b/nix/checks.nix index b5b877f..ec41adf 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -28,16 +28,6 @@ reuse lint touch $out ''; - pycodestyle = - pkgs.runCommandLocal "pycodestyle" - { - nativeBuildInputs = [ pkgs.python3.pkgs.pycodestyle ]; - } - '' - cd ${self.outPath} - pycodestyle --max-line-length 90 $(find . -name "*.py") - touch $out - ''; pylint = pkgs.runCommandLocal "pylint" { diff --git a/nix/devshell.nix b/nix/devshell.nix index 90ecd73..1b418d1 100644 --- a/nix/devshell.nix +++ b/nix/devshell.nix @@ -13,7 +13,7 @@ name = "sbomnix-devshell"; packages = with self'.packages; [ pkgs.python3.pkgs.pylint # for running pylint manually in devshell - pkgs.black # for running black manually in devshell + pkgs.ruff # for running ruff manually in devshell pkgs.isort # for running isort manually in devshell sbomnix.propagatedBuildInputs sbomnix.nativeBuildInputs diff --git a/nix/treefmt.nix b/nix/treefmt.nix index 7204de1..a1be3da 100644 --- a/nix/treefmt.nix +++ b/nix/treefmt.nix @@ -19,12 +19,13 @@ inherit (config.flake-root) projectRootFile; programs = { - black.enable = true; # lints python https://github.com/psf/black deadnix.enable = true; # removes dead nix code https://github.com/astro/deadnix isort.enable = true; # sort python imports https://github.com/PyCQA/isort shellcheck.enable = true; # lints shell scripts https://github.com/koalaman/shellcheck nixfmt.enable = true; # nix formatter https://github.com/NixOS/nixfmt nixfmt.package = pkgs.nixfmt-rfc-style; # rfc-166 formatting conform version + ruff-check.enable = true; # lints python https://github.com/astral-sh/ruff + ruff-format.enable = true; # format python https://github.com/astral-sh/ruff statix.enable = true; # prevents use of nix anti-patterns https://github.com/nerdypepper/statix }; };