提交 67e1819d authored 作者: Virgile Andreani's avatar Virgile Andreani 提交者: Ricardo Vieira

Fix supplying (base_)compiledir as str

上级 f35ce262
......@@ -1155,14 +1155,14 @@ def _default_compiledirname() -> str:
return safe
def _filter_base_compiledir(path: Path) -> Path:
def _filter_base_compiledir(path: str | Path) -> Path:
# Expand '~' in path
return path.expanduser()
return Path(path).expanduser()
def _filter_compiledir(path: Path) -> Path:
def _filter_compiledir(path: str | Path) -> Path:
# Expand '~' in path
path = path.expanduser()
path = Path(path).expanduser()
# Turn path into the 'real' path. This ensures that:
# 1. There is no relative path, which would fail e.g. when trying to
# import modules from the compile dir.
......
......@@ -3,6 +3,8 @@
import configparser as stdlib_configparser
import io
import pickle
from pathlib import Path
from tempfile import mkdtemp
import pytest
......@@ -19,6 +21,15 @@ def _create_test_config():
)
def test_config_paths():
base_compiledir = mkdtemp()
assert configdefaults._filter_base_compiledir(str(base_compiledir)) == Path(
base_compiledir
)
compiledir = mkdtemp()
assert configdefaults._filter_compiledir(str(compiledir)) == Path(compiledir)
def test_invalid_default():
# Ensure an invalid default value found in the PyTensor code only causes
# a crash if it is not overridden by the user.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论