Skip to content

Commit

Permalink
Restrict to trio unless preview is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
augustelalande committed Jul 8, 2024
1 parent 4ef2faf commit b0e4cd4
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(),
));
}
}

0 comments on commit b0e4cd4

Please sign in to comment.