Skip to content

Commit 60f1a1b

Browse files
jcristcpcloud
authored andcommitted
refactor: simplify _find_backend implementation
1 parent e6acc09 commit 60f1a1b

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

ibis/expr/types/core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,15 @@ def _find_backend(self, *, use_default: bool = False) -> BaseBackend:
227227
"assign a backend instance to "
228228
"`ibis.options.default_backend`."
229229
)
230-
if (default := options.default_backend) is None and use_default:
231-
default = _default_backend()
230+
default = _default_backend() if use_default else None
232231
if default is None:
233232
raise IbisError(
234233
'Expression depends on no backends, and found no default'
235234
)
236235
return default
237236

238237
if len(backends) > 1:
239-
raise ValueError('Multiple backends found')
238+
raise IbisError('Multiple backends found for this expression')
240239

241240
return backends[0]
242241

ibis/tests/expr/test_table.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,10 +1473,7 @@ def test_multiple_db_different_backends():
14731473
backend2_table = con2.table('alltypes')
14741474

14751475
expr = backend1_table.union(backend2_table)
1476-
with pytest.raises(
1477-
ValueError,
1478-
match=re.compile("multiple backends", flags=re.IGNORECASE),
1479-
):
1476+
with pytest.raises(com.IbisError, match="Multiple backends"):
14801477
expr.compile()
14811478

14821479

0 commit comments

Comments
 (0)