Skip to content

Commit

Permalink
Make unreachable a test rule for now (#15252)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Jan 4, 2025
1 parent e4d9fe0 commit f319531
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_linter/src/checkers/ast/analyze/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_linter/src/codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions crates/ruff_linter/src/rules/pylint/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f319531

Please sign in to comment.