mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 22:13:58 -05:00
Add fix:ruff action
This commit is contained in:
parent
7a4f8fdeaf
commit
8d18aaf002
3 changed files with 26 additions and 16 deletions
|
|
@ -197,21 +197,28 @@ pub fn check_python(build: &mut Build) -> Result<()> {
|
|||
},
|
||||
)?;
|
||||
|
||||
let ruff_folders = &[
|
||||
"qt/aqt",
|
||||
"ftl",
|
||||
"pylib/tools",
|
||||
"tools",
|
||||
"python",
|
||||
];
|
||||
let ruff_deps = inputs![
|
||||
glob!["{pylib,ftl,qt,python,tools}/**/*.py"],
|
||||
":pylib:anki",
|
||||
":qt:aqt"
|
||||
];
|
||||
build.add_action("check:ruff", RuffCheck {
|
||||
folders: &[
|
||||
"qt/aqt",
|
||||
"ftl",
|
||||
"pylib/tools",
|
||||
"tools",
|
||||
"python",
|
||||
],
|
||||
deps: inputs![
|
||||
glob!["{pylib,ftl,qt,python,tools}/**/*.py"],
|
||||
":pylib:anki",
|
||||
":qt:aqt"
|
||||
],
|
||||
folders: ruff_folders,
|
||||
deps: ruff_deps.clone(),
|
||||
check_only: true,
|
||||
})?;
|
||||
build.add_action("fix:ruff", RuffCheck {
|
||||
folders: ruff_folders,
|
||||
deps: ruff_deps,
|
||||
check_only: false,
|
||||
})?;
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,20 +247,23 @@ pub fn python_format(build: &mut Build, group: &str, inputs: BuildInput) -> Resu
|
|||
pub struct RuffCheck {
|
||||
pub folders: &'static [&'static str],
|
||||
pub deps: BuildInput,
|
||||
pub check_only: bool,
|
||||
}
|
||||
|
||||
impl BuildAction for RuffCheck {
|
||||
fn command(&self) -> &str {
|
||||
"$ruff check $folders"
|
||||
"$ruff check $folders $mode"
|
||||
}
|
||||
|
||||
fn files(&mut self, build: &mut impl crate::build::FilesHandle) {
|
||||
build.add_inputs("", &self.deps);
|
||||
build.add_inputs("ruff", inputs![":pyenv:ruff"]);
|
||||
build.add_variable("folders", self.folders.join(" "));
|
||||
build.add_variable("mode", if self.check_only { "" } else { "--fix" });
|
||||
|
||||
let hash = simple_hash(&self.deps);
|
||||
build.add_output_stamp(format!("tests/python_ruff_check.{hash}"));
|
||||
let kind = if self.check_only { "check" } else { "fix" };
|
||||
build.add_output_stamp(format!("tests/python_ruff.{kind}.{hash}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ When formatting issues are reported, they can be fixed with
|
|||
./ninja format
|
||||
```
|
||||
|
||||
## Fixing eslint/copyright header issues
|
||||
## Fixing ruff/eslint/copyright header issues
|
||||
|
||||
```
|
||||
./ninja fix
|
||||
|
|
|
|||
Loading…
Reference in a new issue