Skip to content

Commit

Permalink
fix: allow backslashes in app config (file format)
Browse files Browse the repository at this point in the history
Serialize string kwargs to the App constructor as r-strings to allow for
backslashes in file paths (windows).
  • Loading branch information
akshayka committed Sep 4, 2024
1 parent 864a3a7 commit e767dbd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion marimo/_ast/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def generate_unparsable_cell(
def generate_app_constructor(config: Optional[_AppConfig]) -> str:
def _format_arg(arg: Any) -> str:
if isinstance(arg, str):
return f'"{arg}"'
# Serialize string arguments as r-strings to handle backslashes
# in file paths
return f'r"{arg}"'
else:
return str(arg)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import marimo

__generated_with = "0.4.6"
app = marimo.App(width="full", app_title="test_title")
app = marimo.App(width=r"full", app_title=r"test_title", css_file=r"a\b.css")



Expand Down
4 changes: 3 additions & 1 deletion tests/_ast/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def test_generate_filecontents_empty() -> None:

@staticmethod
def test_generate_filecontents_empty_with_config() -> None:
config = _AppConfig(app_title="test_title", width="full")
config = _AppConfig(
app_title="test_title", width="full", css_file=r"a\b.css"
)
contents = wrap_generate_filecontents([], [], config=config)
assert contents == get_expected_filecontents(
"test_generate_filecontents_empty_with_config"
Expand Down

0 comments on commit e767dbd

Please sign in to comment.