mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
Set convention in flake8-to-ruff (#1410)
This commit is contained in:
parent
0a60eb0aca
commit
6a7c3728ee
2 changed files with 13 additions and 5 deletions
|
@ -4,11 +4,12 @@ use anyhow::Result;
|
||||||
use ruff::checks_gen::CheckCodePrefix;
|
use ruff::checks_gen::CheckCodePrefix;
|
||||||
use ruff::flake8_quotes::settings::Quote;
|
use ruff::flake8_quotes::settings::Quote;
|
||||||
use ruff::flake8_tidy_imports::settings::Strictness;
|
use ruff::flake8_tidy_imports::settings::Strictness;
|
||||||
|
use ruff::pydocstyle::settings::Convention;
|
||||||
use ruff::settings::options::Options;
|
use ruff::settings::options::Options;
|
||||||
use ruff::settings::pyproject::Pyproject;
|
use ruff::settings::pyproject::Pyproject;
|
||||||
use ruff::{
|
use ruff::{
|
||||||
flake8_annotations, flake8_bugbear, flake8_errmsg, flake8_quotes, flake8_tidy_imports, mccabe,
|
flake8_annotations, flake8_bugbear, flake8_errmsg, flake8_quotes, flake8_tidy_imports, mccabe,
|
||||||
pep8_naming,
|
pep8_naming, pydocstyle,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::black::Black;
|
use crate::black::Black;
|
||||||
|
@ -91,6 +92,7 @@ pub fn convert(
|
||||||
let mut flake8_tidy_imports = flake8_tidy_imports::settings::Options::default();
|
let mut flake8_tidy_imports = flake8_tidy_imports::settings::Options::default();
|
||||||
let mut mccabe = mccabe::settings::Options::default();
|
let mut mccabe = mccabe::settings::Options::default();
|
||||||
let mut pep8_naming = pep8_naming::settings::Options::default();
|
let mut pep8_naming = pep8_naming::settings::Options::default();
|
||||||
|
let mut pydocstyle = pydocstyle::settings::Options::default();
|
||||||
for (key, value) in flake8 {
|
for (key, value) in flake8 {
|
||||||
if let Some(value) = value {
|
if let Some(value) = value {
|
||||||
match key.as_str() {
|
match key.as_str() {
|
||||||
|
@ -200,9 +202,12 @@ pub fn convert(
|
||||||
_ => eprintln!("Unexpected '{key}' value: {value}"),
|
_ => eprintln!("Unexpected '{key}' value: {value}"),
|
||||||
},
|
},
|
||||||
// flake8-docstrings
|
// flake8-docstrings
|
||||||
"docstring-convention" => {
|
"docstring-convention" => match value.trim() {
|
||||||
// No-op (handled above).
|
"google" => pydocstyle.convention = Some(Convention::Google),
|
||||||
}
|
"numpy" => pydocstyle.convention = Some(Convention::Numpy),
|
||||||
|
"pep257" | "all" => pydocstyle.convention = None,
|
||||||
|
_ => eprintln!("Unexpected '{key}' value: {value}"),
|
||||||
|
},
|
||||||
// mccabe
|
// mccabe
|
||||||
"max-complexity" | "max_complexity" => match value.clone().parse::<usize>() {
|
"max-complexity" | "max_complexity" => match value.clone().parse::<usize>() {
|
||||||
Ok(max_complexity) => mccabe.max_complexity = Some(max_complexity),
|
Ok(max_complexity) => mccabe.max_complexity = Some(max_complexity),
|
||||||
|
@ -247,6 +252,9 @@ pub fn convert(
|
||||||
if pep8_naming != pep8_naming::settings::Options::default() {
|
if pep8_naming != pep8_naming::settings::Options::default() {
|
||||||
options.pep8_naming = Some(pep8_naming);
|
options.pep8_naming = Some(pep8_naming);
|
||||||
}
|
}
|
||||||
|
if pydocstyle != pydocstyle::settings::Options::default() {
|
||||||
|
options.pydocstyle = Some(pydocstyle);
|
||||||
|
}
|
||||||
|
|
||||||
// Extract any settings from the existing `pyproject.toml`.
|
// Extract any settings from the existing `pyproject.toml`.
|
||||||
if let Some(black) = black {
|
if let Some(black) = black {
|
||||||
|
|
|
@ -60,7 +60,7 @@ mod pandas_vet;
|
||||||
pub mod pep8_naming;
|
pub mod pep8_naming;
|
||||||
pub mod printer;
|
pub mod printer;
|
||||||
mod pycodestyle;
|
mod pycodestyle;
|
||||||
mod pydocstyle;
|
pub mod pydocstyle;
|
||||||
mod pyflakes;
|
mod pyflakes;
|
||||||
mod pygrep_hooks;
|
mod pygrep_hooks;
|
||||||
mod pylint;
|
mod pylint;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue