Skip to content

Commit 9230347

Browse files
committed
style
Signed-off-by: fresioAS <andreas.fredhoi@three60energy.com> Signed-off-by: Andreas Fredhøi <andreas.fredhoi@fresio.no>
1 parent 9bcacef commit 9230347

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

sqlmesh/core/engine_adapter/fabric.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,23 @@ def _connected_catalog(self) -> t.Optional[str]:
6767
def _connected_catalog(self, value: t.Optional[str]) -> None:
6868
self._connection_pool.set_attribute("connected_catalog", value)
6969

70-
def _normalize_catalog(
71-
self, catalog_name: t.Optional[str]
72-
) -> t.Optional[str]:
70+
def _normalize_catalog(self, catalog_name: t.Optional[str]) -> t.Optional[str]:
7371
if not catalog_name:
7472
return None
7573

76-
default_catalog = (
77-
self._default_catalog or self._extra_config.get("database")
78-
)
74+
default_catalog = self._default_catalog or self._extra_config.get("database")
7975
if default_catalog and catalog_name == default_catalog:
8076
return None
8177

8278
return catalog_name
8379

8480
def _catalog_state_label(self, catalog_name: t.Optional[str]) -> str:
85-
return catalog_name or self._default_catalog or self._extra_config.get("database") or "<default>"
81+
return (
82+
catalog_name
83+
or self._default_catalog
84+
or self._extra_config.get("database")
85+
or "<default>"
86+
)
8687

8788
@property
8889
def api_client(self) -> FabricHttpClient:
@@ -172,9 +173,7 @@ def set_current_catalog(self, catalog_name: t.Optional[str]) -> None:
172173

173174
# No-op: the logical catalog state already matches.
174175
if self.get_current_catalog() == target_catalog:
175-
logger.debug(
176-
"Already using requested Fabric catalog state, no action needed"
177-
)
176+
logger.debug("Already using requested Fabric catalog state, no action needed")
178177
return
179178

180179
# Decide whether the open connection needs to be replaced.
@@ -194,9 +193,7 @@ def set_current_catalog(self, catalog_name: t.Optional[str]) -> None:
194193
# restore-to-neutral left the connection on the right catalog, we
195194
# skip the close entirely.
196195
connected_catalog = self._normalize_catalog(self._connected_catalog)
197-
needs_reconnect = (
198-
target_catalog is not None and connected_catalog != target_catalog
199-
)
196+
needs_reconnect = target_catalog is not None and connected_catalog != target_catalog
200197

201198
if needs_reconnect:
202199
logger.info(

tests/core/engine_adapter/test_fabric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def test_switching_between_catalogs_closes_each_time(
137137
close_spy = mocker.spy(adapter._connection_pool, "close")
138138
adapter.cursor.fetchone.return_value = (1,)
139139

140-
adapter.table_exists("safran.db.table") # None→safran: 1 close
141-
adapter.table_exists("planning.db.table") # safran→planning: 2nd close
140+
adapter.table_exists("safran.db.table") # None→safran: 1 close
141+
adapter.table_exists("planning.db.table") # safran→planning: 2nd close
142142

143143
assert close_spy.call_count == 2
144144
assert adapter._connected_catalog == "planning"

0 commit comments

Comments
 (0)