mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
dev: Switch to ruff for python linting & formatting
It combines multiple tools and is much faster.
This commit is contained in:
1 parent
0d54c7ad3f
commit
da8a997397
6 files changed
+15
-16
No files matched your search
Vendored
+2
-3
@@ -4,8 +4,7 @@
|
||||
"jnoortheen.nix-ide",
|
||||
"ms-python.python",
|
||||
"ms-python.debugpy",
|
||||
"ms-python.black-formatter",
|
||||
"ms-python.isort",
|
||||
"ms-python.mypy-type-checker"
|
||||
"ms-python.mypy-type-checker",
|
||||
"charliermarsh.ruff"
|
||||
]
|
||||
}
|
||||
@@ -80,15 +80,13 @@
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
name = "disko-dev";
|
||||
packages = with pkgs; [
|
||||
packages = (with pkgs; [
|
||||
ruff # Formatter and linter
|
||||
(python3.withPackages (ps: [
|
||||
ps.black # Code formatter
|
||||
ps.isort # Import sorter
|
||||
ps.mypy # Static type checker
|
||||
ps.autoflake # Remove unused imports automatically
|
||||
ps.pytest # Test runner
|
||||
]))
|
||||
];
|
||||
]);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -110,6 +108,7 @@
|
||||
nixpkgs-fmt
|
||||
deno
|
||||
deadnix
|
||||
ruff
|
||||
];
|
||||
text = ''
|
||||
showUsage() {
|
||||
@@ -154,12 +153,16 @@
|
||||
nixpkgs-fmt -- "''${files[@]}"
|
||||
deno fmt -- "''${files[@]}"
|
||||
deadnix --edit -- "''${files[@]}"
|
||||
ruff check --fix
|
||||
ruff format
|
||||
else
|
||||
set -o xtrace
|
||||
|
||||
nixpkgs-fmt --check -- "''${files[@]}"
|
||||
deno fmt --check -- "''${files[@]}"
|
||||
deadnix -- "''${files[@]}"
|
||||
ruff check
|
||||
ruff format --check
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ def parse_args() -> argparse.Namespace:
|
||||
add_common_apply_args(parser)
|
||||
|
||||
# Other commands
|
||||
generate_parser = mode_parsers.add_parser(
|
||||
_generate_parser = mode_parsers.add_parser(
|
||||
"generate",
|
||||
help=MODE_DESCRIPTION["generate"],
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import argparse
|
||||
import json
|
||||
from logging import info
|
||||
from typing import Any, assert_never
|
||||
|
||||
from disko_lib.ansi import Colors
|
||||
|
||||
@@ -2,7 +2,7 @@ import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from disko_lib.logging import ReadableMessage
|
||||
from .colors import *
|
||||
from .colors import PLACEHOLDER, RESET, FLAG, COMMAND, INVALID, FILE, VALUE, EM, EM_WARN
|
||||
|
||||
ERR_ARGUMENTS_HELP_TXT = f"Provide either {PLACEHOLDER}disko_file{RESET} as the second argument or \
|
||||
{FLAG}--flake{RESET}/{FLAG}-f{RESET} {PLACEHOLDER}flake-uri{RESET}."
|
||||
@@ -12,7 +12,7 @@ def err_command_failed(*, command: str, exit_code: int, stderr: str) -> Readable
|
||||
return ReadableMessage(
|
||||
"error",
|
||||
f"""
|
||||
Command failed: {COMMAND}{command}{COMMAND}
|
||||
Command failed: {COMMAND}{command}{RESET}
|
||||
Exit code: {INVALID}{exit_code}{RESET}
|
||||
stderr: {stderr}
|
||||
""",
|
||||
@@ -20,7 +20,6 @@ def err_command_failed(*, command: str, exit_code: int, stderr: str) -> Readable
|
||||
|
||||
|
||||
def err_eval_config_failed(*, args: dict[str, Any], stderr: str) -> ReadableMessage:
|
||||
|
||||
return ReadableMessage(
|
||||
"error",
|
||||
f"""
|
||||
@@ -51,7 +50,7 @@ def err_missing_arguments() -> list[ReadableMessage]:
|
||||
return [
|
||||
ReadableMessage(
|
||||
"error",
|
||||
f"Missing arguments!",
|
||||
"Missing arguments!",
|
||||
),
|
||||
ReadableMessage("help", ERR_ARGUMENTS_HELP_TXT),
|
||||
]
|
||||
@@ -61,7 +60,7 @@ def err_too_many_arguments() -> list[ReadableMessage]:
|
||||
return [
|
||||
ReadableMessage(
|
||||
"error",
|
||||
f"Too many arguments!",
|
||||
"Too many arguments!",
|
||||
),
|
||||
ReadableMessage("help", ERR_ARGUMENTS_HELP_TXT),
|
||||
]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import json
|
||||
from pathlib import Path, PosixPath
|
||||
import pytest
|
||||
|
||||
from disko_lib.messages import err_unsupported_pttype, warn_generate_partial_failure
|
||||
from disko_lib.result import DiskoError, DiskoSuccess
|
||||
|
||||
Reference in new issue
Block a user