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>,