Skip to content

MB005: invalid-syntax

🚨 Breaking ❌ Not Fixable

MB005: Cell contains code that throws a SyntaxError on compilation.

What it does

Attempts to compile each cell using marimo's internal compiler and catches any SyntaxError exceptions that occur during the compilation process.

Why is this bad?

Cells with syntax errors cannot be executed, making the notebook non-functional. SyntaxErrors prevent marimo from creating the dependency graph and running the reactive execution system, breaking the core functionality of the notebook.

Examples

Problematic:

# Invalid indentation
if True:
print("Hello")  # Missing indentation

Problematic:

# Invalid syntax
x = 1 +  # Missing operand

Problematic:

# Mismatched brackets
my_list = [1, 2, 3  # Missing closing bracket

Solution:

# Fix indentation
if True:
    print("Hello")  # Proper indentation

Solution:

# Complete expressions
x = 1 + 2  # Complete arithmetic expression

Solution:

# Match brackets
my_list = [1, 2, 3]  # Proper closing bracket

References