diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 3d04055c8c9..491030a15a2 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -24,4 +24,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + with: + python-version: '3.x' - uses: pre-commit/action@v3.0.1 diff --git a/Cargo.toml b/Cargo.toml index 7f54021495e..0b256b36a80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,6 +89,7 @@ string_lit_as_bytes = "warn" # string_to_string = "warn" todo = "warn" trait_duplication_in_bounds = "warn" +uninlined_format_args = "warn" verbose_file_reads = "warn" # wildcard_imports = "warn" zero_sized_map_values = "warn" diff --git a/clap_builder/src/output/usage.rs b/clap_builder/src/output/usage.rs index bbaa73136fd..d1b861c6ac0 100644 --- a/clap_builder/src/output/usage.rs +++ b/clap_builder/src/output/usage.rs @@ -109,7 +109,7 @@ impl<'cmd> Usage<'cmd> { { self.write_arg_usage(styled, &[], true); styled.trim_end(); - let _ = write!(styled, "{}", USAGE_SEP); + let _ = write!(styled, "{USAGE_SEP}"); } let mut cmd = self.cmd.clone(); cmd.build(); @@ -120,7 +120,7 @@ impl<'cmd> Usage<'cmd> { { if i != 0 { styled.trim_end(); - let _ = write!(styled, "{}", USAGE_SEP); + let _ = write!(styled, "{USAGE_SEP}"); } Usage::new(sub).write_usage_no_title(styled, &[]); } @@ -183,7 +183,7 @@ impl<'cmd> Usage<'cmd> { || self.cmd.is_args_conflicts_with_subcommands_set() { styled.trim_end(); - let _ = write!(styled, "{}", USAGE_SEP); + let _ = write!(styled, "{USAGE_SEP}"); if self.cmd.is_args_conflicts_with_subcommands_set() { let bin_name = self.cmd.get_usage_name_fallback(); // Short-circuit full usage creation since no args will be relevant diff --git a/clap_complete/examples/exhaustive.rs b/clap_complete/examples/exhaustive.rs index 61ca89ff2ec..2c00a2c7111 100644 --- a/clap_complete/examples/exhaustive.rs +++ b/clap_complete/examples/exhaustive.rs @@ -16,7 +16,7 @@ fn main() { return; } - println!("{:?}", matches); + println!("{matches:?}"); } fn print_completions(gen: G, cmd: &mut clap::Command) { diff --git a/clap_complete/src/aot/shells/bash.rs b/clap_complete/src/aot/shells/bash.rs index 5da32d14a63..d283401949d 100644 --- a/clap_complete/src/aot/shells/bash.rs +++ b/clap_complete/src/aot/shells/bash.rs @@ -196,7 +196,7 @@ fn option_details_for_path(cmd: &Command, path: &str) -> String { if let Some(copt) = compopt { v.extend([ r#"if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then"#.to_string(), - format!(" {}", copt), + format!(" {copt}"), "fi".to_string(), ]); } @@ -229,7 +229,7 @@ fn option_details_for_path(cmd: &Command, path: &str) -> String { if let Some(copt) = compopt { v.extend([ r#"if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then"#.to_string(), - format!(" {}", copt), + format!(" {copt}"), "fi".to_string(), ]); } diff --git a/clap_complete/src/aot/shells/elvish.rs b/clap_complete/src/aot/shells/elvish.rs index b41f035ec75..9c276332df4 100644 --- a/clap_complete/src/aot/shells/elvish.rs +++ b/clap_complete/src/aot/shells/elvish.rs @@ -72,7 +72,7 @@ fn generate_inner(p: &Command, previous_command_name: &str) -> String { } else { p.get_name_and_visible_aliases() .into_iter() - .map(|name| format!("{};{}", previous_command_name, name)) + .map(|name| format!("{previous_command_name};{name}")) .collect() }; diff --git a/clap_complete/src/aot/shells/fish.rs b/clap_complete/src/aot/shells/fish.rs index a87dd1d5f07..647e856f1e9 100644 --- a/clap_complete/src/aot/shells/fish.rs +++ b/clap_complete/src/aot/shells/fish.rs @@ -178,7 +178,7 @@ fn gen_fish_inner( for subcommand_name in subcommand.get_name_and_visible_aliases() { let mut template = basic_template.clone(); - template.push_str(format!(" -a \"{}\"", subcommand_name).as_str()); + template.push_str(format!(" -a \"{subcommand_name}\"").as_str()); if let Some(data) = subcommand.get_about() { template.push_str(format!(" -d '{}'", escape_help(data)).as_str()); diff --git a/clap_complete/src/aot/shells/powershell.rs b/clap_complete/src/aot/shells/powershell.rs index 0b71865707e..13e4a61f351 100644 --- a/clap_complete/src/aot/shells/powershell.rs +++ b/clap_complete/src/aot/shells/powershell.rs @@ -77,7 +77,7 @@ fn generate_inner(p: &Command, previous_command_name: &str) -> String { } else { p.get_name_and_visible_aliases() .into_iter() - .map(|name| format!("{};{}", previous_command_name, name)) + .map(|name| format!("{previous_command_name};{name}")) .collect() }; @@ -106,10 +106,9 @@ fn generate_inner(p: &Command, previous_command_name: &str) -> String { for command_name in &command_names { subcommands_cases.push_str(&format!( r" - '{}' {{{} + '{command_name}' {{{completions} break - }}", - command_name, completions + }}" )); } diff --git a/clap_complete/src/engine/complete.rs b/clap_complete/src/engine/complete.rs index b60e084ae3a..72528070213 100644 --- a/clap_complete/src/engine/complete.rs +++ b/clap_complete/src/engine/complete.rs @@ -198,15 +198,15 @@ fn complete_arg( completions.extend( complete_arg_value(value.to_str().ok_or(value), arg, current_dir) .into_iter() - .map(|comp| comp.add_prefix(format!("--{}=", flag))), + .map(|comp| comp.add_prefix(format!("--{flag}="))), ); } } else { completions.extend(longs_and_visible_aliases(cmd).into_iter().filter( - |comp| comp.get_value().starts_with(format!("--{}", flag).as_str()), + |comp| comp.get_value().starts_with(format!("--{flag}").as_str()), )); completions.extend(hidden_longs_aliases(cmd).into_iter().filter(|comp| { - comp.get_value().starts_with(format!("--{}", flag).as_str()) + comp.get_value().starts_with(format!("--{flag}").as_str()) })); } } @@ -428,9 +428,9 @@ fn longs_and_visible_aliases(p: &clap::Command) -> Vec { p.get_arguments() .filter_map(|a| { a.get_long_and_visible_aliases().map(|longs| { - longs.into_iter().map(|s| { - populate_arg_candidate(CompletionCandidate::new(format!("--{}", s)), a) - }) + longs + .into_iter() + .map(|s| populate_arg_candidate(CompletionCandidate::new(format!("--{s}")), a)) }) }) .flatten() @@ -445,8 +445,7 @@ fn hidden_longs_aliases(p: &clap::Command) -> Vec { .filter_map(|a| { a.get_aliases().map(|longs| { longs.into_iter().map(|s| { - populate_arg_candidate(CompletionCandidate::new(format!("--{}", s)), a) - .hide(true) + populate_arg_candidate(CompletionCandidate::new(format!("--{s}")), a).hide(true) }) }) }) diff --git a/clap_complete/src/env/mod.rs b/clap_complete/src/env/mod.rs index b1815f14c9a..3e4524ad38b 100644 --- a/clap_complete/src/env/mod.rs +++ b/clap_complete/src/env/mod.rs @@ -260,7 +260,7 @@ impl<'s, F: FnOnce() -> clap::Command> CompleteEnv<'s, F> { completer.to_owned() } else { let mut completer = std::path::PathBuf::from(completer); - if let Some(current_dir) = current_dir.as_deref() { + if let Some(current_dir) = current_dir { if 1 < completer.components().count() { completer = current_dir.join(completer); } diff --git a/clap_complete/src/env/shells.rs b/clap_complete/src/env/shells.rs index 521cb43e99f..7296647567c 100644 --- a/clap_complete/src/env/shells.rs +++ b/clap_complete/src/env/shells.rs @@ -121,7 +121,7 @@ impl FromStr for CompType { "33" => Ok(Self::Alternatives), "64" => Ok(Self::Unmodified), "37" => Ok(Self::Menu), - _ => Err(format!("unsupported COMP_TYPE `{}`", s)), + _ => Err(format!("unsupported COMP_TYPE `{s}`")), } } } diff --git a/clap_complete/tests/testsuite/bash.rs b/clap_complete/tests/testsuite/bash.rs index 8d63c68992f..33946e14aca 100644 --- a/clap_complete/tests/testsuite/bash.rs +++ b/clap_complete/tests/testsuite/bash.rs @@ -193,8 +193,7 @@ fn complete() { && actual.contains("b_file") && actual.contains("c_dir") && actual.contains("d_dir"), - "Actual output:\n{}", - actual + "Actual output:\n{actual}" ); let input = format!( @@ -207,8 +206,7 @@ fn complete() { && !actual.contains("b_file") && actual.contains("c_dir") && actual.contains("d_dir"), - "Actual output:\n{}", - actual + "Actual output:\n{actual}" ); } diff --git a/clap_complete/tests/testsuite/common.rs b/clap_complete/tests/testsuite/common.rs index d388718dec4..282119d34f3 100644 --- a/clap_complete/tests/testsuite/common.rs +++ b/clap_complete/tests/testsuite/common.rs @@ -429,8 +429,7 @@ pub(crate) fn has_command(command: &str) -> bool { // CI is expected to support all of the commands if is_ci() && cfg!(target_os = "linux") { panic!( - "expected command `{}` to be somewhere in PATH: {}", - command, e + "expected command `{command}` to be somewhere in PATH: {e}" ); } return false; @@ -450,8 +449,7 @@ pub(crate) fn has_command(command: &str) -> bool { let stdout = String::from_utf8_lossy(&output.stdout); println!( "$ {command} --version -{}", - stdout +{stdout}" ); if cfg!(target_os = "macos") && stdout.starts_with("GNU bash, version 3") { return false; diff --git a/clap_complete_nushell/examples/test.rs b/clap_complete_nushell/examples/test.rs index 6cfd416b278..6db15178b18 100644 --- a/clap_complete_nushell/examples/test.rs +++ b/clap_complete_nushell/examples/test.rs @@ -7,7 +7,7 @@ fn main() { let mut cmd = cli(); generate(Nushell, &mut cmd, "test", &mut std::io::stdout()); } else { - println!("{:?}", matches); + println!("{matches:?}"); } } diff --git a/clap_complete_nushell/tests/common.rs b/clap_complete_nushell/tests/common.rs index 9ed9b5ba82d..7063d81d01e 100644 --- a/clap_complete_nushell/tests/common.rs +++ b/clap_complete_nushell/tests/common.rs @@ -375,10 +375,7 @@ pub(crate) fn has_command(command: &str) -> bool { Err(e) => { // CI is expected to support all of the commands if is_ci() && cfg!(target_os = "linux") { - panic!( - "expected command `{}` to be somewhere in PATH: {}", - command, e - ); + panic!("expected command `{command}` to be somewhere in PATH: {e}"); } return false; } @@ -397,8 +394,7 @@ pub(crate) fn has_command(command: &str) -> bool { let stdout = String::from_utf8_lossy(&output.stdout); println!( "$ {command} --version -{}", - stdout +{stdout}" ); if cfg!(target_os = "macos") && stdout.starts_with("GNU bash, version 3") { return false; diff --git a/clap_mangen/src/render.rs b/clap_mangen/src/render.rs index 39377a1ad0b..81d4e8c6b1c 100644 --- a/clap_mangen/src/render.rs +++ b/clap_mangen/src/render.rs @@ -11,7 +11,7 @@ pub(crate) fn subcommand_heading(cmd: &clap::Command) -> &str { pub(crate) fn about(roff: &mut Roff, cmd: &clap::Command) { let name = cmd.get_display_name().unwrap_or_else(|| cmd.get_name()); let s = match cmd.get_about().or_else(|| cmd.get_long_about()) { - Some(about) => format!("{} - {}", name, about), + Some(about) => format!("{name} - {about}"), None => name.to_owned(), }; roff.text([roman(s)]);