Skip to content

Commit

Permalink
feat(pylint): only apply for python versions 3.8 and up
Browse files Browse the repository at this point in the history
  • Loading branch information
vincevannoort committed Sep 7, 2024
1 parent 4aa74b2 commit 07d2997
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ruff_python_semantic::SemanticModel;
use ruff_source_file::Locator;
use ruff_text_size::Ranged;

use crate::{checkers::ast::Checker, fix::edits::delete_stmt};
use crate::{checkers::ast::Checker, fix::edits::delete_stmt, settings::types::PythonVersion};

/// ## What it does
/// Check for cases where an assignment is directly followed by an if statement, these can be combined into a single statement using the `:=` operator.
Expand Down Expand Up @@ -71,6 +71,10 @@ type AssignmentBeforeIfStmt<'a> = (Expr, ExprName, StmtAssign);

/// PLR6103
pub(crate) fn unnecessary_assignment(checker: &mut Checker, stmt: &StmtIf) {
if checker.settings.target_version < PythonVersion::Py38 {
return;
}

let if_test = *stmt.test.clone();
let semantic = checker.semantic();
let mut errors: Vec<AssignmentBeforeIfStmt> = Vec::new();
Expand Down

0 comments on commit 07d2997

Please sign in to comment.