Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions marimo/_config/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ def find_nearest_pyproject_toml(
"""Find the nearest pyproject.toml file."""
path = Path(start_path)
root = path.anchor
while not path.joinpath("pyproject.toml").exists():
if str(path) == root:
return None
if path.parent == path:
return None
path = path.parent
try:
while not path.joinpath("pyproject.toml").exists():
if str(path) == root:
return None
if path.parent == path:
return None
path = path.parent
except OSError:
return None
return path.joinpath("pyproject.toml")
11 changes: 9 additions & 2 deletions tests/_config/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_read_pyproject_config_no_file(tmp_path: Path):
assert nearest_pyproject_toml is None


def testfind_nearest_pyproject_toml():
def test_find_nearest_pyproject_toml():
with tempfile.TemporaryDirectory() as temp_dir:
parent_dir = os.path.join(temp_dir, "parent")
os.makedirs(parent_dir)
Expand All @@ -125,12 +125,19 @@ def testfind_nearest_pyproject_toml():
assert result == Path(pyproject_path)


def testfind_nearest_pyproject_toml_not_found():
def test_find_nearest_pyproject_toml_not_found():
with tempfile.TemporaryDirectory() as temp_dir:
result = find_nearest_pyproject_toml(temp_dir)
assert result is None


def test_find_nearest_pyproject_toml_permission_error():
with patch("pathlib.Path.exists") as mock_exists:
mock_exists.side_effect = PermissionError("Permission denied")
result = find_nearest_pyproject_toml("/some/path")
assert result is None


def test_read_toml_invalid_content():
invalid_toml = b"""
[invalid
Expand Down
Loading