Skip to content

Commit 9c65e5c

Browse files
committed
allow properties to be None
1 parent 1ccae1f commit 9c65e5c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

geojson_pydantic/features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Feature(GenericModel, Generic[Geom, Props]):
1717

1818
type: Literal["Feature"]
1919
geometry: Union[Geom, None] = Field(...)
20-
properties: Props = Field(...)
20+
properties: Union[Props, None] = Field(...)
2121
id: Optional[str] = None
2222
bbox: Optional[BBox] = None
2323

tests/test_features.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,20 @@ def test_feature_collection_geo_interface_with_null_geometry():
192192

193193
def test_feature_validation():
194194
"""Test default."""
195+
assert Feature(type="Feature", properties=None, geometry=None)
196+
195197
with pytest.raises(ValidationError):
196198
# should be type=Feature
197-
Feature(type="feature", properties={}, geometry=None)
199+
Feature(type="feature", properties=None, geometry=None)
200+
201+
with pytest.raises(ValidationError):
202+
# missing type
203+
Feature(properties=None, geometry=None)
198204

199205
with pytest.raises(ValidationError):
200-
# should be properties={}
201-
Feature(type="Feature", properties=None, geometry=None)
206+
# missing properties
207+
Feature(type="Feature", geometry=None)
202208

203209
with pytest.raises(ValidationError):
204-
# should be geometry=None
205-
Feature(type="Feature", properties={})
210+
# missing geometry
211+
Feature(type="Feature", properties=None)

0 commit comments

Comments
 (0)