From f61f47864ade3bb7c6402962488c5e1d0bbafc7f Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 8 Sep 2023 08:45:26 +0200 Subject: [PATCH] Code review feedback --- Cargo.lock | 1 - crates/ruff_python_formatter/Cargo.toml | 1 - crates/ruff_python_formatter/src/expression/mod.rs | 8 +++++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec542070a5d62a..35d0f9e8771233 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2367,7 +2367,6 @@ dependencies = [ "clap", "countme", "insta", - "is-macro", "itertools", "memchr", "once_cell", diff --git a/crates/ruff_python_formatter/Cargo.toml b/crates/ruff_python_formatter/Cargo.toml index 1aae33a9edc0b6..8e7a3b55ad6484 100644 --- a/crates/ruff_python_formatter/Cargo.toml +++ b/crates/ruff_python_formatter/Cargo.toml @@ -23,7 +23,6 @@ anyhow = { workspace = true } bitflags = { workspace = true } clap = { workspace = true } countme = "3.0.1" -is-macro = { workspace = true } itertools = { workspace = true } memchr = { workspace = true } once_cell = { workspace = true } diff --git a/crates/ruff_python_formatter/src/expression/mod.rs b/crates/ruff_python_formatter/src/expression/mod.rs index 39af5b79e9e378..ca8cffd40b0051 100644 --- a/crates/ruff_python_formatter/src/expression/mod.rs +++ b/crates/ruff_python_formatter/src/expression/mod.rs @@ -706,7 +706,7 @@ impl CallChainLayout { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, is_macro::Is)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub(crate) enum OwnParentheses { /// The node has parentheses, but they are empty (e.g., `[]` or `f()`). Empty, @@ -714,6 +714,12 @@ pub(crate) enum OwnParentheses { NonEmpty, } +impl OwnParentheses { + const fn is_non_empty(self) -> bool { + matches!(self, OwnParentheses::NonEmpty) + } +} + /// Returns the [`OwnParentheses`] value for a given [`Expr`], to indicate whether it has its /// own parentheses or is itself parenthesized. ///