From 2e225d7538429f7c451c457f1c7d62ff4a8e514e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 18 Oct 2023 20:14:20 -0400 Subject: [PATCH] Accept `--target-version` in the format CLI (#8055) ## Summary This doesn't affect behavior _yet_ (see: https://github.com/astral-sh/ruff/issues/7234), but it will be needed in the future, and it's surprising to users that it doesn't exist. Closes https://github.com/astral-sh/ruff/issues/8051. --- crates/ruff_cli/src/args.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ruff_cli/src/args.rs b/crates/ruff_cli/src/args.rs index 8a1006a6e6484..f4b7182a2e6f5 100644 --- a/crates/ruff_cli/src/args.rs +++ b/crates/ruff_cli/src/args.rs @@ -398,7 +398,9 @@ pub struct FormatCommand { /// The name of the file when passing it through stdin. #[arg(long, help_heading = "Miscellaneous")] pub stdin_filename: Option, - + /// The minimum Python version that should be supported. + #[arg(long, value_enum)] + pub target_version: Option, /// Enable preview mode; enables unstable formatting. /// Use `--no-preview` to disable. #[arg(long, overrides_with("no_preview"))] @@ -539,6 +541,7 @@ impl FormatCommand { exclude: self.exclude, preview: resolve_bool_arg(self.preview, self.no_preview).map(PreviewMode::from), force_exclude: resolve_bool_arg(self.force_exclude, self.no_force_exclude), + target_version: self.target_version, // Unsupported on the formatter CLI, but required on `Overrides`. ..CliOverrides::default() },