Skip to content

Commit 607521b

Browse files
authored
Merge pull request #207 from loicreynier/feat-add-pylint
Add Pylint & flake8
2 parents 32dcd71 + e441160 commit 607521b

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ use nix
112112

113113
- [black](https://github.com/psf/black)
114114
- [isort](https://github.com/PyCQA/isort)
115+
- [pylint](https://github.com/PyCQA/pylint)
116+
- [flake8](https://github.com/PyCQA/flake8)
115117

116118
## Rust
117119

modules/hooks.nix

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,54 @@ in
204204
};
205205

206206
};
207+
208+
pylint =
209+
{
210+
binPath =
211+
mkOption {
212+
type = types.str;
213+
description = lib.mdDoc "Pylint binary path. Should be used to specify Pylint binary from your Nix-managed Python environment.";
214+
default = "${pkgs.python39Packages.pylint}/bin/pylint";
215+
defaultText = lib.literalExpression ''
216+
"''${pkgs.python39Packages.pylint}/bin/pylint"
217+
'';
218+
};
219+
220+
reports =
221+
mkOption {
222+
type = types.bool;
223+
description = lib.mdDoc "Whether to display a full report.";
224+
default = false;
225+
};
226+
227+
score =
228+
mkOption {
229+
type = types.bool;
230+
description = lib.mdDoc "Whether to activate the evaluation score.";
231+
default = true;
232+
};
233+
};
234+
235+
flake8 =
236+
{
237+
binPath =
238+
mkOption {
239+
type = types.str;
240+
description = lib.mdDoc "flake8 binary path. Should be used to specify flake8 binary from your Nix-managed Python environment.";
241+
default = "${pkgs.python39Packages.flake8}/bin/flake8";
242+
defaultText = lib.literalExpression ''
243+
"''${pkgs.python39Packages.pylint}/bin/flake8"
244+
'';
245+
};
246+
247+
format =
248+
mkOption {
249+
type = types.str;
250+
description = lib.mdDoc "Output format.";
251+
default = "default";
252+
};
253+
};
254+
207255
};
208256

209257
config.hooks =
@@ -674,5 +722,22 @@ in
674722
types = [ "file" ];
675723
};
676724

725+
pylint =
726+
{
727+
name = "pylint";
728+
description = "Lint Python files.";
729+
entry = with settings.pylint;
730+
"${binPath} ${lib.optionalString reports "-ry"} ${lib.optionalString (! score) "-sn"}";
731+
types = [ "python" ];
732+
};
733+
734+
flake8 =
735+
{
736+
name = "flake8";
737+
description = "Check the style and quality of Python files.";
738+
entry = "${settings.flake8.binPath} --format ${settings.flake8.format}";
739+
types = [ "python" ];
740+
};
741+
677742
};
678743
}

0 commit comments

Comments
 (0)