Skip to content

Commit 655f96a

Browse files
committed
Remove mypy ignore directive at shape/dict/geo_interface coercion block
1 parent 666f2cc commit 655f96a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/shapefile.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,10 @@ def __init__(
23272327
# Close and delete the temporary zipfile
23282328
try:
23292329
zipfileobj.close()
2330+
# TODO Does catching all possible exceptions really increase
2331+
# the chances of closing the zipfile successully, or does it
2332+
# just mean .close() failures will still fail, but fail
2333+
# silently?
23302334
except: # noqa: E722
23312335
pass
23322336
# Try to load shapefile
@@ -3550,15 +3554,16 @@ def shape(
35503554
# Check is shape or import from geojson
35513555
if not isinstance(s, Shape):
35523556
if hasattr(s, "__geo_interface__"):
3553-
s = s.__geo_interface__ # type: ignore [assignment]
3557+
shape_dict = cast(dict, s.__geo_interface__)
35543558
if isinstance(s, dict):
3555-
s = Shape._from_geojson(s)
3559+
shape_dict = s
35563560
else:
35573561
raise TypeError(
35583562
"Can only write Shape objects, GeoJSON dictionaries, "
35593563
"or objects with the __geo_interface__, "
35603564
f"not: {s}"
35613565
)
3566+
s = Shape._from_geojson(shape_dict)
35623567
# Write to file
35633568
offset, length = self.__shpRecord(s)
35643569
if self.shx:

0 commit comments

Comments
 (0)