COMPAT: keep old exception sublcasses as (deprecated) ShapelyError aliases
@@ -56,3 +56,26 @@ class GeometryTypeError(ShapelyError):
An error raised when the type of the geometry in question is
unrecognized or inappropriate.
"""
+
+
+def __getattr__(name):
+ import warnings
+
+ # Alias Shapely 1.8 error classes to ShapelyError with deprecation warning
+ if name in [
+ "ReadingError",
+ "WKBReadingError",
+ "WKTReadingError",
+ "PredicateError",
+ "InvalidGeometryError",
+ ]:
+ warnings.warn(
+ f"{name} is deprecated and will be removed in a future version. "
+ "Use ShapelyError instead (functions previously raising {name} "
+ "will now raise a ShapelyError instead).",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return ShapelyError
+
+ raise AttributeError(f"module 'shapely.errors' has no attribute '{name}'")
