Skip to content

Commit

Permalink
fix(api): disambiguate attribute errors from a missing resolve method
Browse files Browse the repository at this point in the history
Previously we caught `AttributeError`s to consider values that aren't
`Deferred` instances as resolved.

However, we caught the `AttributeError` during resolution of the
`resolve` attribute _and_ resolution of the deferred value against an
object.

This commit scopes that to only the `resolve` attribute, other errors
are bubbled up as usual.
  • Loading branch information
cpcloud authored and gforsyth committed Apr 5, 2023
1 parent f600c90 commit e12c4df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ibis/expr/deferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def __neg__(self) -> Deferred:


def _resolve(arg: Any, *, expr: ir.Expr) -> Any:
try:
return arg.resolve(expr)
except AttributeError:
return arg
if (func := getattr(arg, "resolve", None)) is not None:
return func(expr)
return arg
12 changes: 12 additions & 0 deletions ibis/expr/tests/test_deferred.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest

import ibis


def test_invalid_attribute():
from ibis import _

t = ibis.table(dict(a="int"), name="t")
d = _.a + _.b
with pytest.raises(AttributeError):
d.resolve(t)

0 comments on commit e12c4df

Please sign in to comment.