Skip to content

Commit 0a54796

Browse files
authored
Feat: allow passing config to context with expected type (#1748)
* feat: allow passing config to context with expected type * chore: add updated type hint to init
1 parent ed10986 commit 0a54796

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

sqlmesh/core/context.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def __init__(
236236
notification_targets: t.Optional[t.List[NotificationTarget]] = None,
237237
state_sync: t.Optional[StateSync] = None,
238238
paths: t.Union[str, t.Iterable[str]] = "",
239-
config: t.Optional[t.Union[Config, str]] = None,
239+
config: t.Optional[t.Union[Config, str, t.Dict[Path, Config]]] = None,
240240
gateway: t.Optional[str] = None,
241241
concurrent_tasks: t.Optional[int] = None,
242242
loader: t.Optional[t.Type[Loader]] = None,
@@ -248,13 +248,16 @@ def __init__(
248248

249249
self.sqlmesh_path = Path.home() / ".sqlmesh"
250250

251-
self.configs = self._load_configs(
252-
config or "config",
253-
[
254-
Path(path).absolute()
255-
for path in ([paths] if isinstance(paths, str) else list(paths))
256-
],
257-
)
251+
if isinstance(config, dict):
252+
self.configs = config
253+
else:
254+
self.configs = self._load_configs(
255+
config or "config",
256+
[
257+
Path(path).absolute()
258+
for path in ([paths] if isinstance(paths, str) else list(paths))
259+
],
260+
)
258261

259262
self.dag: DAG[str] = DAG()
260263
self._models: UniqueKeyDict[str, Model] = UniqueKeyDict("models")

0 commit comments

Comments
 (0)