Skip to content

Commit 2e72f2d

Browse files
committed
add formatter for python
1 parent ba504d5 commit 2e72f2d

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

pyproject.toml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ scripts = { nixos-anywhere-pxe = "nixos_anywhere_pxe:main"}
1212
addopts = "--cov . --cov-report term --cov-fail-under=100 --no-cov-on-fail"
1313

1414
[tool.mypy]
15-
python_version = "3.10"
15+
python_version = "3.12"
1616
warn_redundant_casts = true
1717
disallow_untyped_calls = true
1818
disallow_untyped_defs = true
@@ -29,8 +29,51 @@ ignore_missing_imports = true
2929
[tool.ruff]
3030
line-length = 88
3131

32-
select = ["E", "F", "I"]
33-
ignore = [ "E501" ]
32+
lint.select = ["ALL"]
33+
lint.ignore = [
34+
# pydocstyle
35+
"D",
36+
# todo comments
37+
"TD",
38+
# fixmes
39+
"FIX",
40+
# line length
41+
"E501",
42+
"T201", # `print` found
43+
"PLR2004", # Magic value used in comparison
44+
# Too many statements
45+
"PLR0915",
46+
# Too many arguments in function definition
47+
"PLR0913",
48+
"PLR0912", # Too many branches
49+
# $X is too complex
50+
"C901",
51+
# Unused function argument
52+
"ARG001",
53+
54+
# Dynamically typed expressions (typing.Any)
55+
"ANN401",
56+
# Trailing comma missing
57+
"COM812",
58+
# Unnecessary `dict` call (rewrite as a literal)
59+
"C408",
60+
# Found commented-out code
61+
"ERA001",
62+
# Boolean-typed positional argument in function definition
63+
"FBT001",
64+
# Logging statement uses f-string
65+
"G004",
66+
# disabled on ruff's recommendation as causes problems with the formatter
67+
"ISC001",
68+
# Use of `assert` detected
69+
"S101",
70+
# `subprocess` call: check for execution of untrusted input
71+
"S603",
72+
# Starting a process with a partial executable path
73+
"S607",
74+
# Boolean default positional argument in function definition
75+
"FBT002",
76+
]
3477

3578
[tool.black]
3679
line-length = 88

treefmt/flake-module.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
imports = [
33
inputs.treefmt-nix.flakeModule
44
];
5-
perSystem = { config, pkgs, ... }: {
5+
perSystem = { config, lib, pkgs, ... }: {
66
treefmt = {
77
projectRootFile = "flake.nix";
88
programs.mdsh.enable = true;
99
programs.nixpkgs-fmt.enable = true;
1010
programs.shellcheck.enable = true;
1111
programs.shfmt.enable = true;
1212
programs.deno.enable = !pkgs.deno.meta.broken;
13+
programs.ruff.format = true;
14+
programs.ruff.check = true;
1315
settings.formatter.shellcheck.options = [ "-s" "bash" ];
1416
};
1517
formatter = config.treefmt.build.wrapper;

0 commit comments

Comments
 (0)