Skip to content

Commit e8a9c82

Browse files
author
Jon Duckworth
authored
Merge pull request #498 from l0b0/print-human-readable-type-name-in-error-messages
feat: Print human readable type name in error messages
2 parents 301f663 + c364212 commit e8a9c82

25 files changed

+143
-18
lines changed

pystac/extensions/datacube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> "DatacubeExtension[T]":
356356
return cast(DatacubeExtension[T], AssetDatacubeExtension(obj))
357357
else:
358358
raise pystac.ExtensionTypeError(
359-
f"Datacube extension does not apply to type {type(obj)}"
359+
f"Datacube extension does not apply to type '{type(obj).__name__}'"
360360
)
361361

362362

pystac/extensions/eo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> "EOExtension[T]":
370370
return cast(EOExtension[T], AssetEOExtension(obj))
371371
else:
372372
raise pystac.ExtensionTypeError(
373-
f"EO extension does not apply to type {type(obj)}"
373+
f"EO extension does not apply to type '{type(obj).__name__}'"
374374
)
375375

376376
@staticmethod

pystac/extensions/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def ext(cls, obj: pystac.Asset, add_if_missing: bool = False) -> "FileExtension"
206206
return cls(obj)
207207
else:
208208
raise pystac.ExtensionTypeError(
209-
f"File Info extension does not apply to type {type(obj)}"
209+
f"File Info extension does not apply to type '{type(obj).__name__}'"
210210
)
211211

212212

pystac/extensions/item_assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def ext(
126126
return cls(obj)
127127
else:
128128
raise pystac.ExtensionTypeError(
129-
f"Item Assets extension does not apply to type {type(obj)}"
129+
f"Item Assets extension does not apply to type '{type(obj).__name__}'"
130130
)
131131

132132

pystac/extensions/label.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def ext(cls, obj: pystac.Item, add_if_missing: bool = False) -> "LabelExtension"
710710
return cls(obj)
711711
else:
712712
raise pystac.ExtensionTypeError(
713-
f"Label extension does not apply to type {type(obj)}"
713+
f"Label extension does not apply to type '{type(obj).__name__}'"
714714
)
715715

716716
@staticmethod

pystac/extensions/pointcloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> "PointcloudExtension[T]":
536536
return cast(PointcloudExtension[T], AssetPointcloudExtension(obj))
537537
else:
538538
raise pystac.ExtensionTypeError(
539-
f"Pointcloud extension does not apply to type {type(obj)}"
539+
f"Pointcloud extension does not apply to type '{type(obj).__name__}'"
540540
)
541541

542542

pystac/extensions/projection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> "ProjectionExtension[T]":
261261
return cast(ProjectionExtension[T], AssetProjectionExtension(obj))
262262
else:
263263
raise pystac.ExtensionTypeError(
264-
f"Projection extension does not apply to type {type(obj)}"
264+
f"Projection extension does not apply to type '{type(obj).__name__}'"
265265
)
266266

267267
@staticmethod

pystac/extensions/raster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def ext(cls, obj: pystac.Asset, add_if_missing: bool = False) -> "RasterExtensio
706706
return cls(obj)
707707
else:
708708
raise pystac.ExtensionTypeError(
709-
f"Raster extension does not apply to type {type(obj)}"
709+
f"Raster extension does not apply to type '{type(obj).__name__}'"
710710
)
711711

712712
@staticmethod

pystac/extensions/sat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> "SatExtension[T]":
109109
return cast(SatExtension[T], AssetSatExtension(obj))
110110
else:
111111
raise pystac.ExtensionTypeError(
112-
f"File extension does not apply to type {type(obj)}"
112+
f"Satellite extension does not apply to type '{type(obj).__name__}'"
113113
)
114114

115115

pystac/extensions/scientific.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> "ScientificExtension[T]":
248248
return cast(ScientificExtension[T], ItemScientificExtension(obj))
249249
else:
250250
raise pystac.ExtensionTypeError(
251-
f"File extension does not apply to type {type(obj)}"
251+
f"Scientific extension does not apply to type '{type(obj).__name__}'"
252252
)
253253

254254
@staticmethod

0 commit comments

Comments
 (0)