From 945150705bb1c877b7edde86fd250bcde963233e Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 15 Jul 2023 16:50:46 -0400 Subject: [PATCH] Gate RuntimeImportInTypeCheckingBlock behind enabled flag --- crates/ruff/src/checkers/ast/mod.rs | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index 94a6aa63972e5d..76efc0224dd692 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -5008,18 +5008,26 @@ impl<'a> Checker<'a> { .collect() }; - flake8_type_checking::rules::runtime_import_in_type_checking_block( - self, - scope, - &mut diagnostics, - ); + if self.enabled(Rule::RuntimeImportInTypeCheckingBlock) { + flake8_type_checking::rules::runtime_import_in_type_checking_block( + self, + scope, + &mut diagnostics, + ); + } - flake8_type_checking::rules::typing_only_runtime_import( - self, - scope, - &runtime_imports, - &mut diagnostics, - ); + if self.any_enabled(&[ + Rule::TypingOnlyFirstPartyImport, + Rule::TypingOnlyThirdPartyImport, + Rule::TypingOnlyStandardLibraryImport, + ]) { + flake8_type_checking::rules::typing_only_runtime_import( + self, + scope, + &runtime_imports, + &mut diagnostics, + ); + } } if self.enabled(Rule::UnusedImport) {