Use #[expect(lint)] over #[allow(lint)] where possible (#17822)

This commit is contained in:
Micha Reiser 2025-05-03 21:20:31 +02:00 committed by GitHub
parent 8535af8516
commit fa628018b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
148 changed files with 221 additions and 268 deletions

View file

@ -273,7 +273,6 @@ impl Configuration {
project_root: project_root.to_path_buf(),
},
#[allow(deprecated)]
linter: LinterSettings {
rules,
exclude: FilePatternSet::try_from_iter(lint.exclude.unwrap_or_default())?,
@ -668,7 +667,7 @@ pub struct LintConfiguration {
impl LintConfiguration {
fn from_options(options: LintOptions, project_root: &Path) -> Result<Self> {
#[allow(deprecated)]
#[expect(deprecated)]
let ignore = options
.common
.ignore
@ -676,7 +675,7 @@ impl LintConfiguration {
.flatten()
.chain(options.common.extend_ignore.into_iter().flatten())
.collect();
#[allow(deprecated)]
#[expect(deprecated)]
let unfixable = options
.common
.unfixable
@ -685,7 +684,7 @@ impl LintConfiguration {
.chain(options.common.extend_unfixable.into_iter().flatten())
.collect();
#[allow(deprecated)]
#[expect(deprecated)]
let ignore_init_module_imports = {
if options.common.ignore_init_module_imports.is_some() {
warn_user_once!("The `ignore-init-module-imports` option is deprecated and will be removed in a future release. Ruff's handling of imports in `__init__.py` files has been improved (in preview) and unused imports will always be flagged.");
@ -1193,7 +1192,6 @@ pub struct FormatConfiguration {
}
impl FormatConfiguration {
#[allow(clippy::needless_pass_by_value)]
pub fn from_options(options: FormatOptions, project_root: &Path) -> Result<Self> {
Ok(Self {
// `--extension` is a hidden command-line argument that isn't supported in configuration
@ -1231,7 +1229,6 @@ impl FormatConfiguration {
}
#[must_use]
#[allow(clippy::needless_pass_by_value)]
pub fn combine(self, config: Self) -> Self {
Self {
exclude: self.exclude.or(config.exclude),
@ -1260,7 +1257,6 @@ pub struct AnalyzeConfiguration {
}
impl AnalyzeConfiguration {
#[allow(clippy::needless_pass_by_value)]
pub fn from_options(options: AnalyzeOptions, project_root: &Path) -> Result<Self> {
Ok(Self {
exclude: options.exclude.map(|paths| {
@ -1287,7 +1283,6 @@ impl AnalyzeConfiguration {
}
#[must_use]
#[allow(clippy::needless_pass_by_value)]
pub fn combine(self, config: Self) -> Self {
Self {
exclude: self.exclude.or(config.exclude),
@ -1339,7 +1334,7 @@ fn warn_about_deprecated_top_level_lint_options(
top_level_options: &LintCommonOptions,
path: Option<&Path>,
) {
#[allow(deprecated)]
#[expect(deprecated)]
let LintCommonOptions {
allowed_confusables,
dummy_variable_rgx,
@ -1659,7 +1654,6 @@ mod tests {
Rule::BlankLinesBeforeNestedDefinition,
];
#[allow(clippy::needless_pass_by_value)]
fn resolve_rules(
selections: impl IntoIterator<Item = RuleSelection>,
preview: Option<PreviewOptions>,

View file

@ -1150,14 +1150,14 @@ impl Flake8BanditOptions {
extend_markup_names: self
.extend_markup_names
.or_else(|| {
#[allow(deprecated)]
#[expect(deprecated)]
ruff_options.and_then(|options| options.extend_markup_names.clone())
})
.unwrap_or_default(),
allowed_markup_calls: self
.allowed_markup_calls
.or_else(|| {
#[allow(deprecated)]
#[expect(deprecated)]
ruff_options.and_then(|options| options.allowed_markup_calls.clone())
})
.unwrap_or_default(),
@ -1308,7 +1308,7 @@ pub struct Flake8BuiltinsOptions {
impl Flake8BuiltinsOptions {
pub fn into_settings(self) -> ruff_linter::rules::flake8_builtins::settings::Settings {
#[allow(deprecated)]
#[expect(deprecated)]
ruff_linter::rules::flake8_builtins::settings::Settings {
ignorelist: self
.ignorelist
@ -3951,7 +3951,7 @@ impl From<LintOptionsWire> for LintOptions {
} = value;
LintOptions {
#[allow(deprecated)]
#[expect(deprecated)]
common: LintCommonOptions {
allowed_confusables,
dummy_variable_rgx,

View file

@ -399,7 +399,7 @@ strict-checking = false
"#,
)?;
#[allow(deprecated)]
#[expect(deprecated)]
let expected = Flake8BuiltinsOptions {
builtins_allowed_modules: Some(vec!["asyncio".to_string()]),
allowed_modules: Some(vec!["sys".to_string()]),

View file

@ -19,7 +19,6 @@ use std::fmt;
use std::path::{Path, PathBuf};
#[derive(Debug, CacheKey)]
#[allow(clippy::struct_excessive_bools)]
pub struct Settings {
#[cache_key(ignore)]
pub cache_dir: PathBuf,