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.

feat: PathState follows os.PathLike ABC (#8403)

Andrew Glick0c5ed8216202
diff --git a/marimo/_runtime/watch/__init__.py b/marimo/_runtime/watch/__init__.py
index d52377b8f4..c000ee018e 100644
--- a/marimo/_runtime/watch/__init__.py
+++ b/marimo/_runtime/watch/__init__.py
@@ -1,7 +1,8 @@
# Copyright 2026 Marimo. All rights reserved.
-from marimo._runtime.watch._directory import directory
-from marimo._runtime.watch._file import file
+from marimo._runtime.watch._directory import DirectoryState, directory
+from marimo._runtime.watch._file import FileState, file
+from marimo._runtime.watch._path import PathState
# NB. _runtime/reload captures module level changes and
# marimo/_server/sessions.py captures notebook level changes.
@@ -9,4 +10,7 @@ from marimo._runtime.watch._file import file
__all__ = [
"file",
"directory",
+ "FileState",
+ "DirectoryState",
+ "PathState",
]
diff --git a/marimo/_runtime/watch/_path.py b/marimo/_runtime/watch/_path.py
index a16bd067f4..7dd5ad5580 100644
--- a/marimo/_runtime/watch/_path.py
+++ b/marimo/_runtime/watch/_path.py
@@ -111,6 +111,12 @@ class PathState(State[Path]):
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self._value})"
+ def __fspath__(self) -> str:
+ return self._value.__fspath__()
+
+ def __str__(self) -> str:
+ return str(self._value)
+
def exists(self) -> bool:
"""Check if the path exists."""
exists = self._value.exists()
diff --git a/tests/snapshots/api.txt b/tests/snapshots/api.txt
index c4f76e80e6..f77a695603 100644
--- a/tests/snapshots/api.txt
+++ b/tests/snapshots/api.txt
@@ -124,5 +124,8 @@ ui
video
vstack
watch
+ DirectoryState
+ FileState
+ PathState
directory
file
\ No newline at end of file