From da1026bc47c7e46c7739c4b0e08f004a4ed6a02c Mon Sep 17 00:00:00 2001 From: Patrick Kidger <33688385+patrick-kidger@users.noreply.github.com> Date: Sat, 11 May 2024 20:41:20 +0200 Subject: [PATCH] Fixed crash when not using any extra arguments --- pyproject.toml | 2 +- typst_pyimage/__main__.py | 1 + typst_pyimage/run.py | 8 ++------ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a08a4a6..3135601 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "typst_pyimage" -version = "0.0.4" +version = "0.0.5" description = "Typst extension, adding support for generating figures using inline Python code" readme = "README.md" requires-python = "~=3.8" diff --git a/typst_pyimage/__main__.py b/typst_pyimage/__main__.py index 352709f..f2993fe 100644 --- a/typst_pyimage/__main__.py +++ b/typst_pyimage/__main__.py @@ -77,6 +77,7 @@ def _watch_wrapper(args): "-a", "--extra-args", type=str, + default="", help="Extra arguments to be passed to typst", ) diff --git a/typst_pyimage/run.py b/typst_pyimage/run.py index 374a4cf..c0aabc8 100644 --- a/typst_pyimage/run.py +++ b/typst_pyimage/run.py @@ -156,11 +156,9 @@ def _initial( def watch( filename: Union[str, pathlib.Path], - extra_args: Optional[list[str]] = None, + extra_args: list[str], timeout_s: Optional[int] = None, ): - if extra_args is None: - extra_args = [] figcache = {} contentcache = {} filepath, dirpath, init_code, init_scope = _initial( @@ -190,8 +188,6 @@ def watch( process.kill() -def compile(filename: Union[str, pathlib.Path], extra_args: Optional[list[str]] = None): - if extra_args is None: - extra_args = [] +def compile(filename: Union[str, pathlib.Path], extra_args: list[str]): filepath, _, _, _ = _initial(filename, figcache=None, contentcache=None) subprocess.run(["typst", "compile"] + extra_args + [str(filepath)])