Make unreachable a test rule for now (#15252)

This commit is contained in:
Micha Reiser 2025-01-04 12:52:08 +01:00 committed by GitHub
parent e4d9fe036a
commit f319531632
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 1 deletions

View File

@ -386,7 +386,7 @@ jobs:
- name: "Install Rust toolchain"
run: rustup component add rustfmt
- uses: Swatinem/rust-cache@v2
- run: ./scripts/add_rule.py --name DoTheThing --prefix PL --code C0999 --linter pylint
- run: ./scripts/add_rule.py --name DoTheThing --prefix F --code 999 --linter pyflakes
- run: cargo check
- run: cargo fmt --all --check
- run: |

View File

@ -366,6 +366,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
if checker.enabled(Rule::AsyncFunctionWithTimeout) {
flake8_async::rules::async_function_with_timeout(checker, function_def);
}
#[cfg(any(feature = "test-rules", test))]
if checker.enabled(Rule::UnreachableCode) {
checker
.diagnostics

View File

@ -268,6 +268,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
(Pylint, "R6104") => (RuleGroup::Preview, rules::pylint::rules::NonAugmentedAssignment),
(Pylint, "R6201") => (RuleGroup::Preview, rules::pylint::rules::LiteralMembership),
(Pylint, "R6301") => (RuleGroup::Preview, rules::pylint::rules::NoSelfUse),
#[cfg(any(feature = "test-rules", test))]
(Pylint, "W0101") => (RuleGroup::Preview, rules::pylint::rules::UnreachableCode),
(Pylint, "W0108") => (RuleGroup::Preview, rules::pylint::rules::UnnecessaryLambda),
(Pylint, "W0177") => (RuleGroup::Preview, rules::pylint::rules::NanComparison),

View File

@ -95,6 +95,7 @@ pub(crate) use unnecessary_direct_lambda_call::*;
pub(crate) use unnecessary_dunder_call::*;
pub(crate) use unnecessary_lambda::*;
pub(crate) use unnecessary_list_index_lookup::*;
#[cfg(any(feature = "test-rules", test))]
pub(crate) use unreachable::*;
pub(crate) use unspecified_encoding::*;
pub(crate) use useless_else_on_loop::*;
@ -202,6 +203,7 @@ mod unnecessary_direct_lambda_call;
mod unnecessary_dunder_call;
mod unnecessary_lambda;
mod unnecessary_list_index_lookup;
#[cfg(any(feature = "test-rules", test))]
mod unreachable;
mod unspecified_encoding;
mod useless_else_on_loop;