Add parentheses when simplifying conditions in SIM222 (#7117)

This commit is contained in:
Charlie Marsh 2023-09-03 23:35:59 +01:00 committed by GitHub
parent 32f4a96c64
commit a56121672c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 23 deletions

View file

@ -1,6 +1,5 @@
//! Generate Python source code from an abstract syntax tree (AST).
use ruff_python_ast::{ParameterWithDefault, TypeParams};
use std::ops::Deref;
use ruff_python_ast::{
@ -8,8 +7,8 @@ use ruff_python_ast::{
ExceptHandler, Expr, Identifier, MatchCase, Operator, Parameter, Parameters, Pattern, Stmt,
Suite, TypeParam, TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, WithItem,
};
use ruff_python_ast::{ParameterWithDefault, TypeParams};
use ruff_python_literal::escape::{AsciiEscape, Escape, UnicodeEscape};
use ruff_source_file::LineEnding;
use super::stylist::{Indentation, Quote, Stylist};
@ -1381,12 +1380,12 @@ impl<'a> Generator<'a> {
mod tests {
use ruff_python_ast::{Mod, ModModule};
use ruff_python_parser::{self, parse_suite, Mode};
use ruff_source_file::LineEnding;
use super::Generator;
use crate::stylist::{Indentation, Quote};
use super::Generator;
fn round_trip(contents: &str) -> String {
let indentation = Indentation::default();
let quote = Quote::default();