Skip to content

Commit c5c07eb

Browse files
committed
Begin type annotations of Shape
1 parent 165d99d commit c5c07eb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

shapefile.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,12 @@ def organize_polygon_rings(
443443

444444
class Shape:
445445
def __init__(
446-
self, shapeType=NULL, points=None, parts=None, partTypes=None, oid=None
446+
self,
447+
shapeType: int = NULL,
448+
points: Optional[Coords] = None,
449+
parts: Optional[list[int]] = None,
450+
partTypes: Optional[list[int]] = None,
451+
oid: Optional[int] = None,
447452
):
448453
"""Stores the geometry of the different shape types
449454
specified in the Shapefile spec. Shape types are
@@ -463,7 +468,7 @@ def __init__(
463468
self.partTypes = partTypes
464469

465470
# and a dict to silently record any errors encountered
466-
self._errors = {}
471+
self._errors: dict[str, int] = {}
467472

468473
# add oid
469474
if oid is not None:
@@ -666,12 +671,12 @@ def _from_geojson(geoj):
666671
return shape
667672

668673
@property
669-
def oid(self):
674+
def oid(self) -> int:
670675
"""The index position of the shape in the original shapefile"""
671676
return self.__oid
672677

673678
@property
674-
def shapeTypeName(self):
679+
def shapeTypeName(self) -> str:
675680
return SHAPETYPE_LOOKUP[self.shapeType]
676681

677682
def __repr__(self):

0 commit comments

Comments
 (0)