Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

refactor: Checking if a block is defined should use a set's in operator. (#8735)

Michael Chavinda775012ba381e
diff --git a/marimo/_ast/visitor.py b/marimo/_ast/visitor.py
index a70d17fb31..9c98ba27dd 100644
--- a/marimo/_ast/visitor.py
+++ b/marimo/_ast/visitor.py
@@ -129,7 +129,7 @@ class Block:
is_comprehension: bool = False
def is_defined(self, name: str) -> bool:
- return any(name == defn for defn in self.defs)
+ return name in self.defs
@dataclass