Skip to content

Commit 2afd278

Browse files
authored
Fix: refactor to adapt to changes to shapely dependency (#1376)
* fix: refactored to account for changes in dependency * Removes comment and ensures linting success * refactor to use loads() function * fix: refactors to account for changes to shapely dependency * fix: refactors to account for changes to shapely dependency * blacken the code * add mypy ignore flag for shapely import
1 parent 78db9ea commit 2afd278

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

google/cloud/bigquery/_pandas_helpers.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,9 @@
5757
if pandas is not None: # pragma: NO COVER
5858

5959
def _to_wkb():
60-
# Create a closure that:
61-
# - Adds a not-null check. This allows the returned function to
62-
# be used directly with apply, unlike `shapely.wkb.dumps`.
63-
# - Avoid extra work done by `shapely.wkb.dumps` that we don't need.
64-
# - Caches the WKBWriter (and write method lookup :) )
65-
# - Avoids adding WKBWriter, lgeos, and notnull to the module namespace.
66-
from shapely.geos import WKBWriter, lgeos # type: ignore
67-
68-
write = WKBWriter(lgeos).write
60+
from shapely import wkb # type: ignore
61+
62+
write = wkb.dumps
6963
notnull = pandas.notnull
7064

7165
def _to_wkb(v):

google/cloud/bigquery/table.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
_COORDINATE_REFERENCE_SYSTEM = "EPSG:4326"
4040

4141
try:
42-
import shapely.geos # type: ignore
42+
import shapely # type: ignore
4343
except ImportError:
4444
shapely = None
4545
else:
46-
_read_wkt = shapely.geos.WKTReader(shapely.geos.lgeos).read
46+
_read_wkt = shapely.wkt.loads
4747

4848
import google.api_core.exceptions
4949
from google.api_core.page_iterator import HTTPIterator

0 commit comments

Comments
 (0)