From 2a0d8ff44deb95bf5c4b8ee239a1193542cb03a8 Mon Sep 17 00:00:00 2001 From: Alexey Preobrazhenskiy Date: Mon, 9 Sep 2024 15:27:05 +0200 Subject: [PATCH] [`flake8-pytest-style`] Fix defaults for empty `lint.flake8-pytest-style.*-parentheses` config (`PT001`, `PT023`) --- crates/ruff_workspace/src/configuration.rs | 4 +--- crates/ruff_workspace/src/options.rs | 11 ++++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index f178e91c13182..7e90dab190457 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -327,9 +327,7 @@ impl Configuration { .unwrap_or_default(), flake8_pytest_style: lint .flake8_pytest_style - .map(|options| { - Flake8PytestStyleOptions::try_into_settings(options, lint_preview) - }) + .map(Flake8PytestStyleOptions::try_into_settings) .transpose()? .unwrap_or_default(), flake8_quotes: lint diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index cebb6002b92d4..46de76f40ce18 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -24,7 +24,7 @@ use ruff_linter::rules::{ pycodestyle, pydocstyle, pyflakes, pylint, pyupgrade, ruff, }; use ruff_linter::settings::types::{ - IdentifierPattern, OutputFormat, PreviewMode, PythonVersion, RequiredVersion, + IdentifierPattern, OutputFormat, PythonVersion, RequiredVersion, }; use ruff_linter::{warn_user_once, RuleSelector}; use ruff_macros::{CombineOptions, OptionsMetadata}; @@ -1494,12 +1494,9 @@ pub struct Flake8PytestStyleOptions { } impl Flake8PytestStyleOptions { - pub fn try_into_settings( - self, - preview: PreviewMode, - ) -> anyhow::Result { + pub fn try_into_settings(self) -> anyhow::Result { Ok(flake8_pytest_style::settings::Settings { - fixture_parentheses: self.fixture_parentheses.unwrap_or(preview.is_disabled()), + fixture_parentheses: self.fixture_parentheses.unwrap_or_default(), parametrize_names_type: self.parametrize_names_type.unwrap_or_default(), parametrize_values_type: self.parametrize_values_type.unwrap_or_default(), parametrize_values_row_type: self.parametrize_values_row_type.unwrap_or_default(), @@ -1525,7 +1522,7 @@ impl Flake8PytestStyleOptions { .transpose() .map_err(SettingsError::InvalidRaisesExtendRequireMatchFor)? .unwrap_or_default(), - mark_parentheses: self.mark_parentheses.unwrap_or(preview.is_disabled()), + mark_parentheses: self.mark_parentheses.unwrap_or_default(), }) } }