-
-
Notifications
You must be signed in to change notification settings - Fork 510
Closed
Labels
bugSomething isn't workingSomething isn't workingregressionBehavior has changed for worse with a releaseBehavior has changed for worse with a releasestubsIssues in stubs files (.pyi)Issues in stubs files (.pyi)
Description
Bug report
What's wrong
Iterating on the return type of Layer.get_geoms
throws:
"OGRGeometry" has no attribute "__iter__" (not iterable)
I think these lines are wrong:
django-stubs/django-stubs/contrib/gis/gdal/layer.pyi
Lines 43 to 46 in 2e504df
@overload | |
def get_geoms(self, geos: Literal[True] = ...) -> OGRGeometry: ... | |
@overload | |
def get_geoms(self, geos: Literal[False]) -> GEOSGeometry: ... |
How is that should be
>>> type(layer.get_geoms())
<class 'list'>
>>> type(layer.get_geoms()[0])
<class 'django.contrib.gis.gdal.geometries.Polygon'>
>>> type(layer.get_geoms(geos=True)[0])
<class 'django.contrib.gis.geos.polygon.Polygon'>
I think the type definitions should be as follows (mind also the switched geos
parameter):
@overload
def get_geoms(self, geos: Literal[False] = ...) -> list[OGRGeometry]: ...
@overload
def get_geoms(self, geos: Literal[True]) -> list[GEOSGeometry]: ...
What do you think, @ciscorn?
System information
- OS: Docker image
python:3.9.16-bullseye
python
version: 3.9.16django
version: 4.1.4mypy
version: 0-991django-stubs
version: 1.13.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingregressionBehavior has changed for worse with a releaseBehavior has changed for worse with a releasestubsIssues in stubs files (.pyi)Issues in stubs files (.pyi)