Skip to content

Commit

Permalink
Fix object lookups for Python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kesmit13 committed Jun 9, 2023
1 parent 3ec190d commit 8ee045a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions singlestoredb/http/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
has_pygeos = False

try:
import shapely
import shapely.geometry
import shapely.wkt
has_shapely = True
except ImportError:
Expand Down Expand Up @@ -171,9 +171,9 @@ def b64decode_converter(


if has_shapely:
shapely_Point = shapely.Point
shapely_Polygon = shapely.Polygon
shapely_LineString = shapely.LineString
shapely_Point = shapely.geometry.Point
shapely_Polygon = shapely.geometry.Polygon
shapely_LineString = shapely.geometry.LineString

if has_numpy:
np_ndarray = np.ndarray
Expand Down
11 changes: 4 additions & 7 deletions singlestoredb/mysql/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
has_numpy = False

try:
import shapely
import shapely.geometry
import shapely.wkt
has_shapely = True
except ImportError:
Expand Down Expand Up @@ -209,12 +209,9 @@ def escape_shapely(value, mapping=None):
"""Convert shapely geo objects."""
return escape_str(shapely.wkt.dumps(value), mapping=mapping)

if hasattr(shapely, 'Polygon'):
encoders[shapely.Polygon] = escape_shapely
if hasattr(shapely, 'Point'):
encoders[shapely.Point] = escape_shapely
if hasattr(shapely, 'LineString'):
encoders[shapely.LineString] = escape_shapely
encoders[shapely.geometry.Polygon] = escape_shapely
encoders[shapely.geometry.Point] = escape_shapely
encoders[shapely.geometry.LineString] = escape_shapely

if has_pygeos:

Expand Down

0 comments on commit 8ee045a

Please sign in to comment.