Skip to content

Commit

Permalink
refactor: use rlz.lazy_instance_of to delay shapely import
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Nov 29, 2022
1 parent 4e30480 commit d14badc
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions ibis/expr/operations/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
from ibis.expr.operations.core import Named, Unary, Value
from ibis.util import frozendict

try:
from shapely.geometry.base import BaseGeometry
except ImportError:
BaseGeometry = type(None)


@public
class TableColumn(Value, Named):
Expand Down Expand Up @@ -172,28 +167,32 @@ class Least(Value):

@public
class Literal(Value):
value = rlz.instance_of(
value = rlz.one_of(
(
BaseGeometry,
bytes,
datetime.date,
datetime.datetime,
datetime.time,
datetime.timedelta,
decimal.Decimal,
enum.Enum,
float,
frozendict,
frozenset,
int,
ipaddress.IPv4Address,
ipaddress.IPv6Address,
np.generic,
np.ndarray,
str,
tuple,
type(None),
uuid.UUID,
rlz.instance_of(
(
bytes,
datetime.date,
datetime.datetime,
datetime.time,
datetime.timedelta,
decimal.Decimal,
enum.Enum,
float,
frozendict,
frozenset,
int,
ipaddress.IPv4Address,
ipaddress.IPv6Address,
np.generic,
np.ndarray,
str,
tuple,
type(None),
uuid.UUID,
)
),
rlz.lazy_instance_of("shapely.geometry.BaseGeometry"),
)
)
dtype = rlz.datatype
Expand Down

0 comments on commit d14badc

Please sign in to comment.