Skip to content

Commit ade90b1

Browse files
authored
DOC-1904: Add and update deprecation decorators (#764)
* DOC-1904: Add and update deprecation decorators Add and update deprecation decorators. The migration guide is being updated here: up42/documentation-hub#1953 * Update utils.py * Update punctuation for the decorator * Apply Black * Update asset, catalog, tasking * Added deprecation after the Catalog class definition is complete * Update catalog.py * Update catalog.py * Update tasking.py * Update asset.py * Update asset.py * Update asset.py * simplify asset.py * Remove Type * Update test_storage to keep only fixed lists * Remove deprecation on classes and restore test_storage * Update catalog.py * Update catalog.py * Revert base and webhooks
1 parent 78ed465 commit ade90b1

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

up42/asset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _get_download_url(self, asset_id: str) -> str:
182182
return self.session.post(url=url).json()["url"]
183183

184184
@property
185-
@utils.deprecation("pystac::Asset.file", "3.0.0")
185+
@utils.deprecation(None, "3.0.0")
186186
def file(self) -> utils.ImageFile:
187187
return utils.ImageFile(url=self._get_download_url(self.asset_id))
188188

up42/initialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def initialize_storage() -> storage.Storage:
3131
return storage.Storage()
3232

3333

34-
@utils.deprecation("Order::get", "3.0.0")
34+
@utils.deprecation(None, "3.0.0")
3535
def initialize_order(order_id: str) -> order.Order:
3636
"""
3737
Returns an Order object (has to exist on UP42).
@@ -43,7 +43,7 @@ def initialize_order(order_id: str) -> order.Order:
4343
return up42_order
4444

4545

46-
@utils.deprecation("Asset::get", "3.0.0")
46+
@utils.deprecation(None, "3.0.0")
4747
def initialize_asset(asset_id: str) -> asset.Asset:
4848
"""
4949
Returns an Asset object (has to exist on UP42).

up42/order.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def is_fulfilled(self) -> bool:
212212
"""
213213
return self.status == "FULFILLED"
214214

215-
@utils.deprecation(None, "3.0.0")
215+
@utils.deprecation("pystac::Client.search", "3.0.0")
216216
def get_assets(self) -> List[asset.Asset]:
217217
"""
218218
Gets the Order assets or results.

up42/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Storage:
4040
workspace_id = base.WorkspaceId()
4141
pystac_client = base.StacClient()
4242

43-
@utils.deprecation("Asset::all", "3.0.0")
43+
@utils.deprecation("pystac::Client.search", "3.0.0")
4444
def get_assets(
4545
self,
4646
created_after: Optional[Union[str, dt.datetime]] = None,

up42/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@ def deprecation(
8282
Args:
8383
replacement_name: Name of the replacement function.
8484
version: The breaking package version
85-
extra_message: Optional message after default deprecation warning.
8685
"""
8786

8887
def actual_decorator(func):
8988
@functools.wraps(func)
9089
def wrapper(*args, **kwargs):
91-
replace_with = f", use `{replacement_name}` instead" if replacement_name else ""
92-
message = f"`{func.__name__}` is deprecated and will be dropped in version {version}{replace_with}."
90+
replace_with = f" Use `{replacement_name}` instead." if replacement_name else ""
91+
message = f"`{func.__name__}` is deprecated and will be removed in version {version}{replace_with}."
9392
warnings.warn(message, DeprecationWarning, stacklevel=2)
9493
return func(*args, **kwargs)
9594

0 commit comments

Comments
 (0)