Skip to content

Commit

Permalink
Merge pull request #47 from tesselo/make-feature-geometry-optional
Browse files Browse the repository at this point in the history
make feature geometry optional
  • Loading branch information
vincentsarago authored Mar 4, 2022
2 parents 4608687 + 8c408ab commit 9415f96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion geojson_pydantic/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from geojson_pydantic.types import BBox

Props = TypeVar("Props", bound=Dict)
Geom = TypeVar("Geom", bound=Geometry)
Geom = TypeVar("Geom", bound=Optional[Geometry])


class Feature(GenericModel, Generic[Geom, Props]):
Expand Down
11 changes: 11 additions & 0 deletions test/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class GenericProperties(BaseModel):
"properties": properties,
}

test_feature_geom_null = {
"type": "Feature",
"geometry": None,
"properties": properties,
}


def test_geometry_collection_iteration():
"""test if feature collection is iterable"""
Expand Down Expand Up @@ -100,3 +106,8 @@ class Pointy:

feat = Feature(geometry=Pointy())
assert feat.geometry.dict() == Pointy.__geo_interface__


def test_feature_with_null_geometry():
feature = Feature(**test_feature_geom_null)
assert feature.geometry is None

0 comments on commit 9415f96

Please sign in to comment.