Skip to content

Commit 72116e9

Browse files
committed
style
1 parent 3f6cca8 commit 72116e9

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
@@ -61,22 +61,23 @@ def _connected_catalog(self) -> t.Optional[str]:
6161
def _connected_catalog(self, value: t.Optional[str]) -> None:
6262
self._connection_pool.set_attribute("connected_catalog", value)
6363

64-
def _normalize_catalog(
65-
self, catalog_name: t.Optional[str]
66-
) -> t.Optional[str]:
64+
def _normalize_catalog(self, catalog_name: t.Optional[str]) -> t.Optional[str]:
6765
if not catalog_name:
6866
return None
6967

70-
default_catalog = (
71-
self._default_catalog or self._extra_config.get("database")
72-
)
68+
default_catalog = self._default_catalog or self._extra_config.get("database")
7369
if default_catalog and catalog_name == default_catalog:
7470
return None
7571

7672
return catalog_name
7773

7874
def _catalog_state_label(self, catalog_name: t.Optional[str]) -> str:
79-
return catalog_name or self._default_catalog or self._extra_config.get("database") or "<default>"
75+
return (
76+
catalog_name
77+
or self._default_catalog
78+
or self._extra_config.get("database")
79+
or "<default>"
80+
)
8081

8182
@property
8283
def api_client(self) -> FabricHttpClient:
@@ -166,9 +167,7 @@ def set_current_catalog(self, catalog_name: t.Optional[str]) -> None:
166167

167168
# No-op: the logical catalog state already matches.
168169
if self.get_current_catalog() == target_catalog:
169-
logger.debug(
170-
"Already using requested Fabric catalog state, no action needed"
171-
)
170+
logger.debug("Already using requested Fabric catalog state, no action needed")
172171
return
173172

174173
# Decide whether the open connection needs to be replaced.
@@ -188,9 +187,7 @@ def set_current_catalog(self, catalog_name: t.Optional[str]) -> None:
188187
# restore-to-neutral left the connection on the right catalog, we
189188
# skip the close entirely.
190189
connected_catalog = self._normalize_catalog(self._connected_catalog)
191-
needs_reconnect = (
192-
target_catalog is not None and connected_catalog != target_catalog
193-
)
190+
needs_reconnect = target_catalog is not None and connected_catalog != target_catalog
194191

195192
if needs_reconnect:
196193
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)