Skip to content

Commit f8ef79c

Browse files
committed
More specific STAC_IO deprecation warnings
1 parent e7d4bdc commit f8ef79c

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

docs/api.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,18 @@ RelType
164164
IO
165165
--
166166

167+
StacIO
168+
~~~~~~
169+
170+
.. autoclass:: pystac.StacIO
171+
:members:
172+
:undoc-members:
173+
167174
STAC_IO
168175
~~~~~~~
169176

170-
STAC_IO is the utility mechanism that PySTAC uses for reading and writing. Users of
171-
PySTAC can hook into PySTAC by overriding members to utilize their own IO methods.
177+
.. deprecated:: 1.0.0-beta.1
178+
Use :class:`pystac.StacIO` instead. This class will be removed in v1.0.0.
172179

173180
.. autoclass:: pystac.stac_io.STAC_IO
174181
:members:

pystac/stac_io.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,22 +271,28 @@ class STAC_IO:
271271
"""
272272

273273
@staticmethod
274-
def read_text_method(uri: str) -> str:
274+
def issue_deprecation_warning() -> None:
275275
warnings.warn(
276-
"STAC_IO is deprecated. "
277-
"Please use instances of StacIO (e.g. StacIO.default()).",
276+
"STAC_IO is deprecated and will be removed in v1.0.0. "
277+
"Please use instances of StacIO (e.g. StacIO.default()) instead.",
278278
DeprecationWarning,
279279
)
280+
281+
def __init__(self) -> None:
282+
STAC_IO.issue_deprecation_warning()
283+
284+
def __init_subclass__(cls) -> None:
285+
STAC_IO.issue_deprecation_warning()
286+
287+
@staticmethod
288+
def read_text_method(uri: str) -> str:
289+
STAC_IO.issue_deprecation_warning()
280290
return StacIO.default().read_text(uri)
281291

282292
@staticmethod
283293
def write_text_method(uri: str, txt: str) -> None:
284294
"""Default method for writing text."""
285-
warnings.warn(
286-
"STAC_IO is deprecated. "
287-
"Please use instances of StacIO (e.g. StacIO.default()).",
288-
DeprecationWarning,
289-
)
295+
STAC_IO.issue_deprecation_warning()
290296
return StacIO.default().write_text(uri, txt)
291297

292298
@staticmethod
@@ -295,11 +301,7 @@ def stac_object_from_dict(
295301
href: Optional[str] = None,
296302
root: Optional["Catalog_Type"] = None,
297303
) -> "STACObject_Type":
298-
warnings.warn(
299-
"STAC_IO is deprecated. "
300-
"Please use instances of StacIO (e.g. StacIO.default()).",
301-
DeprecationWarning,
302-
)
304+
STAC_IO.issue_deprecation_warning()
303305
return pystac.serialization.stac_object_from_dict(d, href, root)
304306

305307
# This is set in __init__.py
@@ -356,6 +358,7 @@ def read_json(cls, uri: str) -> Dict[str, Any]:
356358
STAC_IO in order to enable additional URI types, replace that member
357359
with your own implementation.
358360
"""
361+
STAC_IO.issue_deprecation_warning()
359362
result: Dict[str, Any] = json.loads(STAC_IO.read_text(uri))
360363
return result
361364

0 commit comments

Comments
 (0)