From b0e4cd4b8aa3b9169f6a40419ff809be3ddddfd4 Mon Sep 17 00:00:00 2001 From: augustelalande Date: Mon, 8 Jul 2024 15:26:13 -0400 Subject: [PATCH] Restrict to trio unless preview is enabled --- .../rules/async_function_with_timeout.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs b/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs index 7095d07be63ab8..1f624fcde2a664 100644 --- a/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs +++ b/crates/ruff_linter/src/rules/flake8_async/rules/async_function_with_timeout.rs @@ -6,6 +6,7 @@ use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_async::helpers::AsyncModule; +use crate::settings::types::PreviewMode; /// ## What it does /// Checks for `async` functions with a `timeout` argument. @@ -81,8 +82,17 @@ pub(crate) fn async_function_with_timeout( AsyncModule::AsyncIO }; - checker.diagnostics.push(Diagnostic::new( - AsyncFunctionWithTimeout { module }, - timeout.range(), - )); + if matches!(checker.settings.preview, PreviewMode::Disabled) + && matches!(module, AsyncModule::Trio) + { + checker.diagnostics.push(Diagnostic::new( + AsyncFunctionWithTimeout { module }, + timeout.range(), + )); + } else { + checker.diagnostics.push(Diagnostic::new( + AsyncFunctionWithTimeout { module }, + timeout.range(), + )); + } }