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.

fix: ci breakage in python 3.13.8 (#6831)

Dylan Madisetti79dd5667cb91
diff --git a/marimo/_ast/pytest.py b/marimo/_ast/pytest.py
index ee2515f533..e6d8edaba2 100644
--- a/marimo/_ast/pytest.py
+++ b/marimo/_ast/pytest.py
@@ -1,4 +1,4 @@
-# Copyright 2024 Marimo. All rights reserved.
+# Copyright 2025 Marimo. All rights reserved.
from __future__ import annotations
import ast
diff --git a/packages/pytest_changed/__init__.py b/packages/pytest_changed/__init__.py
index cb69577227..50e98e107c 100644
--- a/packages/pytest_changed/__init__.py
+++ b/packages/pytest_changed/__init__.py
@@ -168,24 +168,45 @@ def find_affected_files(
return affected
-def find_test_files(affected_files: set[Path], repo_root: Path) -> set[Path]:
+def get_test_base(config: pytest.Config, repo_root: Path) -> Path:
+ """
+ Get the test base directory from pytest invocation args.
+
+ Args:
+ config: Pytest configuration object
+ repo_root: Repository root to use as fallback
+
+ Returns:
+ Path to test base directory
+ """
+ for arg in config.invocation_params.args:
+ path = Path(arg)
+ if path.exists() and path.is_dir():
+ return path.resolve()
+ return repo_root
+
+
+def find_test_files(affected_files: set[Path], test_base: Path) -> set[Path]:
"""
Filter affected files to only include test files.
Args:
affected_files: Set of all affected files
- repo_root: Root of the repository
+ test_base: Root of the repository
Returns:
Set of test file paths
"""
- del repo_root
test_files: set[Path] = set()
for file_path in affected_files:
- # Check if it's a test file
+ # Check if it's a test file, and relative to the test base
# N.B Our test naming convention is test_*.py
- if file_path.exists() and file_path.name.startswith("test_"):
+ if (
+ file_path.exists()
+ and file_path.name.startswith("test_")
+ and test_base in file_path.parents
+ ):
test_files.add(file_path)
return test_files
@@ -210,6 +231,9 @@ def pytest_configure(config: pytest.Config) -> None:
except subprocess.CalledProcessError:
pytest.exit("Not in a git repository", returncode=1)
+ # Get test base directory from args or fall back to repo root
+ test_base = get_test_base(config, repo_root)
+
# Step 1: Find changed files
changed_files = get_changed_files(changed_from, repo_root)
@@ -234,7 +258,7 @@ def pytest_configure(config: pytest.Config) -> None:
print_(f"Found {len(affected_files)} affected files")
# Step 4: Filter to test files
- test_files = find_test_files(affected_files, repo_root)
+ test_files = find_test_files(affected_files, test_base)
if not test_files:
print_(f"\nNo tests affected by changes from {changed_from}")
diff --git a/tests/_ast/codegen_data/test_generate_filecontents_toplevel.py b/tests/_ast/codegen_data/test_generate_filecontents_toplevel.py
index ccf2f2373b..48a6c9f037 100644
--- a/tests/_ast/codegen_data/test_generate_filecontents_toplevel.py
+++ b/tests/_ast/codegen_data/test_generate_filecontents_toplevel.py
@@ -32,7 +32,6 @@ def _():
@app.function
-# Sanity check that base case works.
def addition(a, b):
return a + b
diff --git a/tests/_ast/test_pytest_toplevel.py b/tests/_ast/test_pytest_toplevel.py
index 61de6131a9..1ab8010fff 100644
--- a/tests/_ast/test_pytest_toplevel.py
+++ b/tests/_ast/test_pytest_toplevel.py
@@ -11,7 +11,6 @@ with app.setup:
@app.function
-# Sanity check that base case works.
def add(a, b):
return a + b
diff --git a/tests/_runtime/script_data/fn_exception.py b/tests/_runtime/script_data/fn_exception.py
index 6a268aaab0..d951a38bff 100644
--- a/tests/_runtime/script_data/fn_exception.py
+++ b/tests/_runtime/script_data/fn_exception.py
@@ -17,7 +17,6 @@ def bad_divide(x, y):
# Also a check for no call
@app.function
-# Technically legal, but messy
def bad_divide_curry(x):
# Filler line
# To push the error
diff --git a/tests/_runtime/test_trace.py b/tests/_runtime/test_trace.py
index b499ddf02b..ac0d80c3a6 100644
--- a/tests/_runtime/test_trace.py
+++ b/tests/_runtime/test_trace.py
@@ -27,7 +27,7 @@ class TestScriptTrace:
result = p.stderr.decode()
assert "ZeroDivisionError: division by zero" in result
assert ('fn_exception.py", line 14') in result
- assert ('fn_exception.py", line 26') in result
+ assert ('fn_exception.py", line 25') in result
assert "bad_divide(0, x)" in result
assert "y / x" in result
# Test col_offset