Skip to content

Commit

Permalink
Use ruff python linter
Browse files Browse the repository at this point in the history
Signed-off-by: Henri Rosten <[email protected]>
  • Loading branch information
henrirosten committed Jan 5, 2025
1 parent 1d58d96 commit 5a324c7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 -- . \
Expand Down
10 changes: 0 additions & 10 deletions nix/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
{
Expand Down
2 changes: 1 addition & 1 deletion nix/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion nix/treefmt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
};
Expand Down

0 comments on commit 5a324c7

Please sign in to comment.