Closed ahokinson closed 6 years ago
I believe the type hinting is incorrect for classes where coordinates are defined by multiple points.
The documentation indicates that the following code should work.
def geojson_serialize(self): return Feature(geometry=LineString(coordinates=[(self.city.longitude, self.city.latitude), (self.host.city.longitude, self.host.city.latitude)]), properties={"attack_type": self.attack_type.name, ...
When run, it does seem to work as intended. However, it produces a weak warning: Expected type 'tuple', got 'List[Tuple[Any,Any]]' instead.
Expected type 'tuple', got 'List[Tuple[Any,Any]]' instead
Because LineString inherits from MultiPoint which inherits from Geometry, it uses the following constructor.
LineString
MultiPoint
Geometry
def __init__(self, coordinates=None, crs=None, validate=False, **extra): """ Initialises a Geometry object. :param coordinates: Coordinates of the Geometry object. :type coordinates: tuple :param crs: CRS :type crs: CRS object """
which is incorrect for any MultiPoint coordinates.
Would the use of typing.Union be an appropriate fix here?
typing.Union
I'm willing to submit a PR.
I believe the type hinting is incorrect for classes where coordinates are defined by multiple points.
The documentation indicates that the following code should work.
When run, it does seem to work as intended. However, it produces a weak warning:
Expected type 'tuple', got 'List[Tuple[Any,Any]]' instead
.Because
LineString
inherits fromMultiPoint
which inherits fromGeometry
, it uses the following constructor.which is incorrect for any
MultiPoint
coordinates.Would the use of
typing.Union
be an appropriate fix here?I'm willing to submit a PR.