@@ -240,7 +240,7 @@ def __repr__(self) -> str:
240240
241241class HasGeoInterface (Protocol ):
242242 @property
243- def __geo_interface__ (self ) -> Any : ...
243+ def __geo_interface__ (self ) -> GeoJSONHomogeneousGeometryObject : ...
244244
245245
246246class GeoJSONPoint (TypedDict ):
@@ -3591,17 +3591,18 @@ def __dbfHeader(self) -> None:
35913591
35923592 def shape (
35933593 self ,
3594- s : Union [Shape , HasGeoInterface , dict [ str , PointsT ] ],
3594+ s : Union [Shape , HasGeoInterface , GeoJSONHomogeneousGeometryObject ],
35953595 ) -> None :
35963596 # Balance if already not balanced
35973597 if self .autoBalance and self .recNum < self .shpNum :
35983598 self .balance ()
35993599 # Check is shape or import from geojson
36003600 if not isinstance (s , Shape ):
36013601 if hasattr (s , "__geo_interface__" ):
3602- shape_dict = cast (GeoJSONHomogeneousGeometryObject , s .__geo_interface__ )
3603- if isinstance (s , dict ):
3604- shape_dict = cast (GeoJSONHomogeneousGeometryObject , s )
3602+ s = cast (HasGeoInterface , s )
3603+ shape_dict = s .__geo_interface__
3604+ elif isinstance (s , dict ): # TypedDict is a dict at runtime
3605+ shape_dict = s
36053606 else :
36063607 raise TypeError (
36073608 "Can only write Shape objects, GeoJSON dictionaries, "
0 commit comments