Skip to content

Commit d480f07

Browse files
authored
feat: context support pathlib.Path paths (#1942)
1 parent 0a84bf5 commit d480f07

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

sqlmesh/core/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def __init__(
256256
engine_adapter: t.Optional[EngineAdapter] = None,
257257
notification_targets: t.Optional[t.List[NotificationTarget]] = None,
258258
state_sync: t.Optional[StateSync] = None,
259-
paths: t.Union[str, t.Iterable[str]] = "",
259+
paths: t.Union[str | Path, t.Iterable[str | Path]] = "",
260260
config: t.Optional[t.Union[Config, str, t.Dict[Path, Config]]] = None,
261261
gateway: t.Optional[str] = None,
262262
concurrent_tasks: t.Optional[int] = None,

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def init_and_plan_context(copy_to_temp_path, mocker) -> t.Callable:
243243
def _make_function(
244244
paths: str | t.List[str] | Path | t.List[Path], config="test_config"
245245
) -> t.Tuple[Context, Plan]:
246-
sushi_context = Context(paths=[str(x) for x in copy_to_temp_path(paths)], config=config)
246+
sushi_context = Context(paths=copy_to_temp_path(paths), config=config)
247247
confirm = mocker.patch("sqlmesh.core.console.Confirm")
248248
confirm.ask.return_value = False
249249

tests/core/test_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def test():
285285
config = Config(
286286
ignore_patterns=["models/ignore/*.sql", "macro_ignore.py", ".ipynb_checkpoints/*"]
287287
)
288-
context = Context(paths=str(tmp_path), config=config)
288+
context = Context(paths=tmp_path, config=config)
289289

290290
assert ['"memory"."db"."actual_test"'] == list(context.models)
291291
assert "test" in context._macros

tests/core/test_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_format_files(tmp_path: pathlib.Path):
2222
)
2323

2424
config = Config()
25-
context = Context(paths=str(tmp_path), config=config)
25+
context = Context(paths=tmp_path, config=config)
2626
context.load()
2727
assert isinstance(context.get_model("this.model"), SqlModel)
2828
assert isinstance(context.get_model("other.model"), SqlModel)

tests/core/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ def get_current_df(context: Context):
17431743
str(tmp_path / "models" / "marketing.sql"),
17441744
)
17451745

1746-
context = Context(paths=[str(tmp_path)], config="test_config")
1746+
context = Context(paths=tmp_path, config="test_config")
17471747
context.engine_adapter.create_schema("sushi")
17481748
replace_source_table(
17491749
context,

tests/core/test_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def test_test_generation(tmp_path: Path) -> None:
451451
model_defaults=ModelDefaultsConfig(dialect="duckdb"),
452452
)
453453

454-
context = Context(paths=[str(tmp_path)], config=config)
454+
context = Context(paths=tmp_path, config=config)
455455
context.plan(auto_apply=True)
456456

457457
input_queries = {

tests/web/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_settings_override() -> Settings:
3939

4040
@pytest.fixture
4141
def project_context(project_tmp_path: Path) -> Context:
42-
context = Context(paths=str(project_tmp_path), console=api_console)
42+
context = Context(paths=project_tmp_path, console=api_console)
4343

4444
def get_loaded_context_override() -> Context:
4545
return context

0 commit comments

Comments
 (0)