Skip to content

chore(ruff): split into ruff-format and ruff-check #213

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 1 commit into from
Aug 28, 2024
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ functions.
* prettier
* protolint
* purs-tidy
* ruff
* ruff-check
* ruff-format
* rufo
* rustfmt
* scalafmt
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions examples/formatter-ruff-format.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example generated by ../examples.sh
[formatter.ruff-format]
command = "ruff"
excludes = []
includes = ["*.py", "*.pyi"]
options = ["format"]
35 changes: 35 additions & 0 deletions programs/ruff-check.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ lib, pkgs, config, ... }:
let
cfg = config.programs.ruff-check;
in
{
meta.maintainers = [ ];

imports = [
(lib.mkRenamedOptionModule [ "programs" "ruff" "check" ] [ "programs" "ruff-check" "enable" ])
(lib.mkRenamedOptionModule [ "programs" "ruff" "enable" ] [ "programs" "ruff-check" "enable" ])
];

options.programs.ruff-check = {
enable = lib.mkEnableOption "ruff linter" // {
description = ''
Whether to enable the Ruff linter, an extremely fast Python linter
designed as a drop-in replacement for Flake8 (plus dozens of plugins),
isort, pydocstyle, pyupgrade, autoflake, and more.
'';
};

package = lib.mkPackageOption pkgs "ruff" { };
};

config = lib.mkIf cfg.enable {
settings.formatter.ruff-check = {
command = cfg.package;
options = lib.mkBefore [ "check" "--fix" ];
includes = [
"*.py"
"*.pyi"
];
};
};
}
33 changes: 33 additions & 0 deletions programs/ruff-format.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ lib, pkgs, config, ... }:
let
cfg = config.programs.ruff-format;
in
{
meta.maintainers = [ ];

imports = [
(lib.mkRenamedOptionModule [ "programs" "ruff" "format" ] [ "programs" "ruff-format" "enable" ])
];

options.programs.ruff-format = {
enable = lib.mkEnableOption "ruff formatter" // {
description = ''
Whether to enable the Ruff formatter, an extremely fast Python code formatter
designed as a drop-in replacement for Black.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd question this bit somewhat, but I see what you mean

'';
};

package = lib.mkPackageOption pkgs "ruff" { };
};

config = lib.mkIf cfg.enable {
settings.formatter.ruff-format = lib.mkIf cfg.enable {
command = cfg.package;
options = lib.mkBefore [ "format" ];
includes = [
"*.py"
"*.pyi"
];
};
};
}
49 changes: 0 additions & 49 deletions programs/ruff.nix

This file was deleted.