Skip to content

Commit fa62801

Browse files
authored
Use #[expect(lint)] over #[allow(lint)] where possible (astral-sh#17822)
1 parent 8535af8 commit fa62801

File tree

148 files changed

+221
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+221
-268
lines changed

crates/ruff/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ fn main() {
1313

1414
commit_info(&workspace_root);
1515

16-
#[allow(clippy::disallowed_methods)]
1716
let target = std::env::var("TARGET").unwrap();
1817
println!("cargo::rustc-env=RUST_HOST_TARGET={target}");
1918
}

crates/ruff/src/args.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub struct Args {
9393
pub(crate) global_options: GlobalConfigArgs,
9494
}
9595

96-
#[allow(clippy::large_enum_variant)]
96+
#[expect(clippy::large_enum_variant)]
9797
#[derive(Debug, clap::Subcommand)]
9898
pub enum Command {
9999
/// Run Ruff on the given files or directories.
@@ -184,7 +184,7 @@ pub struct AnalyzeGraphCommand {
184184

185185
// The `Parser` derive is for ruff_dev, for ruff `Args` would be sufficient
186186
#[derive(Clone, Debug, clap::Parser)]
187-
#[allow(clippy::struct_excessive_bools)]
187+
#[expect(clippy::struct_excessive_bools)]
188188
pub struct CheckCommand {
189189
/// List of files or directories to check.
190190
#[clap(help = "List of files or directories to check [default: .]")]
@@ -446,7 +446,7 @@ pub struct CheckCommand {
446446
}
447447

448448
#[derive(Clone, Debug, clap::Parser)]
449-
#[allow(clippy::struct_excessive_bools)]
449+
#[expect(clippy::struct_excessive_bools)]
450450
pub struct FormatCommand {
451451
/// List of files or directories to format.
452452
#[clap(help = "List of files or directories to format [default: .]")]
@@ -560,7 +560,7 @@ pub enum HelpFormat {
560560
Json,
561561
}
562562

563-
#[allow(clippy::module_name_repetitions)]
563+
#[expect(clippy::module_name_repetitions)]
564564
#[derive(Debug, Default, Clone, clap::Args)]
565565
pub struct LogLevelArgs {
566566
/// Enable verbose logging.
@@ -1031,7 +1031,7 @@ Possible choices:
10311031

10321032
/// CLI settings that are distinct from configuration (commands, lists of files,
10331033
/// etc.).
1034-
#[allow(clippy::struct_excessive_bools)]
1034+
#[expect(clippy::struct_excessive_bools)]
10351035
pub struct CheckArguments {
10361036
pub add_noqa: bool,
10371037
pub diff: bool,
@@ -1050,7 +1050,7 @@ pub struct CheckArguments {
10501050

10511051
/// CLI settings that are distinct from configuration (commands, lists of files,
10521052
/// etc.).
1053-
#[allow(clippy::struct_excessive_bools)]
1053+
#[expect(clippy::struct_excessive_bools)]
10541054
pub struct FormatArguments {
10551055
pub check: bool,
10561056
pub no_cache: bool,
@@ -1271,7 +1271,6 @@ pub struct AnalyzeGraphArgs {
12711271
/// Configuration overrides provided via dedicated CLI flags:
12721272
/// `--line-length`, `--respect-gitignore`, etc.
12731273
#[derive(Clone, Default)]
1274-
#[allow(clippy::struct_excessive_bools)]
12751274
struct ExplicitConfigOverrides {
12761275
dummy_variable_rgx: Option<Regex>,
12771276
exclude: Option<Vec<FilePattern>>,

crates/ruff/src/cache.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub(crate) struct Cache {
8686
changes: Mutex<Vec<Change>>,
8787
/// The "current" timestamp used as cache for the updates of
8888
/// [`FileCache::last_seen`]
89-
#[allow(clippy::struct_field_names)]
89+
#[expect(clippy::struct_field_names)]
9090
last_seen_cache: u64,
9191
}
9292

@@ -146,7 +146,7 @@ impl Cache {
146146
Cache::new(path, package)
147147
}
148148

149-
#[allow(clippy::cast_possible_truncation)]
149+
#[expect(clippy::cast_possible_truncation)]
150150
fn new(path: PathBuf, package: PackageCache) -> Self {
151151
Cache {
152152
path,
@@ -204,7 +204,7 @@ impl Cache {
204204
}
205205

206206
/// Applies the pending changes without storing the cache to disk.
207-
#[allow(clippy::cast_possible_truncation)]
207+
#[expect(clippy::cast_possible_truncation)]
208208
pub(crate) fn save(&mut self) -> bool {
209209
/// Maximum duration for which we keep a file in cache that hasn't been seen.
210210
const MAX_LAST_SEEN: Duration = Duration::from_secs(30 * 24 * 60 * 60); // 30 days.
@@ -834,7 +834,6 @@ mod tests {
834834
// Regression test for issue #3086.
835835

836836
#[cfg(unix)]
837-
#[allow(clippy::items_after_statements)]
838837
fn flip_execute_permission_bit(path: &Path) -> io::Result<()> {
839838
use std::os::unix::fs::PermissionsExt;
840839
let file = fs::OpenOptions::new().write(true).open(path)?;
@@ -843,7 +842,6 @@ mod tests {
843842
}
844843

845844
#[cfg(windows)]
846-
#[allow(clippy::items_after_statements)]
847845
fn flip_read_only_permission(path: &Path) -> io::Result<()> {
848846
let file = fs::OpenOptions::new().write(true).open(path)?;
849847
let mut perms = file.metadata()?.permissions();

crates/ruff/src/commands/check.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use crate::cache::{Cache, PackageCacheMap, PackageCaches};
3030
use crate::diagnostics::Diagnostics;
3131

3232
/// Run the linter over a collection of files.
33-
#[allow(clippy::too_many_arguments)]
3433
pub(crate) fn check(
3534
files: &[PathBuf],
3635
pyproject_config: &PyprojectConfig,
@@ -181,7 +180,6 @@ pub(crate) fn check(
181180

182181
/// Wraps [`lint_path`](crate::diagnostics::lint_path) in a [`catch_unwind`](std::panic::catch_unwind) and emits
183182
/// a diagnostic if the linting the file panics.
184-
#[allow(clippy::too_many_arguments)]
185183
fn lint_path(
186184
path: &Path,
187185
package: Option<PackageRoot<'_>>,

crates/ruff/src/commands/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::args::HelpFormat;
55
use ruff_workspace::options::Options;
66
use ruff_workspace::options_base::OptionsMetadata;
77

8-
#[allow(clippy::print_stdout)]
8+
#[expect(clippy::print_stdout)]
99
pub(crate) fn config(key: Option<&str>, format: HelpFormat) -> Result<()> {
1010
match key {
1111
None => {

crates/ruff/src/commands/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ pub(crate) fn format_source(
362362
})
363363
} else {
364364
// Using `Printed::into_code` requires adding `ruff_formatter` as a direct dependency, and I suspect that Rust can optimize the closure away regardless.
365-
#[allow(clippy::redundant_closure_for_method_calls)]
365+
#[expect(clippy::redundant_closure_for_method_calls)]
366366
format_module_source(unformatted, options).map(|formatted| formatted.into_code())
367367
};
368368

crates/ruff/src/commands/rule.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Explanation<'a> {
1919
summary: &'a str,
2020
message_formats: &'a [&'a str],
2121
fix: String,
22-
#[allow(clippy::struct_field_names)]
22+
#[expect(clippy::struct_field_names)]
2323
explanation: Option<&'a str>,
2424
preview: bool,
2525
}

crates/ruff/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn run(
134134
{
135135
let default_panic_hook = std::panic::take_hook();
136136
std::panic::set_hook(Box::new(move |info| {
137-
#[allow(clippy::print_stderr)]
137+
#[expect(clippy::print_stderr)]
138138
{
139139
eprintln!(
140140
r#"
@@ -326,7 +326,7 @@ pub fn check(args: CheckCommand, global_options: GlobalConfigArgs) -> Result<Exi
326326
commands::add_noqa::add_noqa(&files, &pyproject_config, &config_arguments)?;
327327
if modifications > 0 && config_arguments.log_level >= LogLevel::Default {
328328
let s = if modifications == 1 { "" } else { "s" };
329-
#[allow(clippy::print_stderr)]
329+
#[expect(clippy::print_stderr)]
330330
{
331331
eprintln!("Added {modifications} noqa directive{s}.");
332332
}

crates/ruff/src/printer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ impl Printer {
241241
}
242242

243243
if !self.flags.intersects(Flags::SHOW_VIOLATIONS) {
244-
#[allow(deprecated)]
245244
if matches!(
246245
self.format,
247246
OutputFormat::Full | OutputFormat::Concise | OutputFormat::Grouped

crates/ruff_benchmark/benches/linter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
4545
target_arch = "powerpc64"
4646
)
4747
))]
48-
#[allow(non_upper_case_globals)]
48+
#[expect(non_upper_case_globals)]
4949
#[export_name = "_rjem_malloc_conf"]
50-
#[allow(unsafe_code)]
50+
#[expect(unsafe_code)]
5151
pub static _rjem_malloc_conf: &[u8] = b"dirty_decay_ms:-1,muzzy_decay_ms:-1\0";
5252

5353
fn create_test_cases() -> Vec<TestCase> {

0 commit comments

Comments
 (0)