Skip to content

Add Pylint & flake8 #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ use nix

- [black](https://github.com/psf/black)
- [isort](https://github.com/PyCQA/isort)
- [pylint](https://github.com/PyCQA/pylint)
- [flake8](https://github.com/PyCQA/flake8)

## Rust

Expand Down
65 changes: 65 additions & 0 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,54 @@ in
};

};

pylint =
{
binPath =
mkOption {
type = types.str;
description = lib.mdDoc "Pylint binary path. Should be used to specify Pylint binary from your Nix-managed Python environment.";
default = "${pkgs.python39Packages.pylint}/bin/pylint";
defaultText = lib.literalExpression ''
"''${pkgs.python39Packages.pylint}/bin/pylint"
'';
};

reports =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to display a full report.";
default = false;
};

score =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to activate the evaluation score.";
default = true;
};
};

flake8 =
{
binPath =
mkOption {
type = types.str;
description = lib.mdDoc "flake8 binary path. Should be used to specify flake8 binary from your Nix-managed Python environment.";
default = "${pkgs.python39Packages.flake8}/bin/flake8";
defaultText = lib.literalExpression ''
"''${pkgs.python39Packages.pylint}/bin/flake8"
'';
};

format =
mkOption {
type = types.str;
description = lib.mdDoc "Output format.";
default = "default";
};
};

};

config.hooks =
Expand Down Expand Up @@ -674,5 +722,22 @@ in
types = [ "file" ];
};

pylint =
{
name = "pylint";
description = "Lint Python files.";
entry = with settings.pylint;
"${binPath} ${lib.optionalString reports "-ry"} ${lib.optionalString (! score) "-sn"}";
types = [ "python" ];
};

flake8 =
{
name = "flake8";
description = "Check the style and quality of Python files.";
entry = "${settings.flake8.binPath} --format ${settings.flake8.format}";
types = [ "python" ];
};

};
}