From b7c44a424c31e8884e5d79cfc1268cff633bc5ec Mon Sep 17 00:00:00 2001 From: Tennessee Leeuwenburg Date: Wed, 29 Apr 2026 20:13:32 +1000 Subject: [PATCH 1/2] Remove last known uses of the backwards compatibility decorator Remove the decorator code --- .../pipeline/operations/xarray/reshape.py | 12 ++------ .../src/pyearthtools/utils/decorators.py | 30 ------------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py b/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py index 89959b92..a427d83b 100644 --- a/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py +++ b/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py @@ -23,7 +23,6 @@ from pyearthtools.pipeline.operation import Operation from pyearthtools.data.transforms.attributes import SetType -from pyearthtools.utils.decorators import BackwardsCompatibility T = TypeVar("T", xr.Dataset, xr.DataArray) @@ -185,11 +184,7 @@ def apply_func(self, dataset: xr.Dataset) -> xr.Dataset: return new_ds def undo_func(self, ds): - return pyearthtools.pipeline.operations.xarray.reshape.coordinate_expand(self._coordinate)(ds) - - -@BackwardsCompatibility(CoordinateFlatten) -def coordinate_flatten(*args, **kwargs) -> Operation: ... + return pyearthtools.pipeline.operations.xarray.reshape.CoordinateExpand(self._coordinate)(ds) class CoordinateExpand(Operation): @@ -242,8 +237,5 @@ def apply_func(self, dataset: xr.Dataset) -> xr.Dataset | xr.DataArray: return dataset def undo_func(self, ds): - return pyearthtools.pipeline.operations.xarray.reshape.coordinate_flatten(self._coordinate)(ds) - + return pyearthtools.pipeline.operations.xarray.reshape.CoordinateFlatten(self._coordinate)(ds) -@BackwardsCompatibility(CoordinateExpand) -def coordinate_expand(*args, **kwargs) -> Operation: ... diff --git a/packages/utils/src/pyearthtools/utils/decorators.py b/packages/utils/src/pyearthtools/utils/decorators.py index 5b8679d9..8f35fd78 100644 --- a/packages/utils/src/pyearthtools/utils/decorators.py +++ b/packages/utils/src/pyearthtools/utils/decorators.py @@ -94,33 +94,3 @@ def wrapper(*args, **kwargs): return internal_function -def BackwardsCompatibility(new_func: C) -> Callable[[C], C]: - """ - Allows for the renaming of a functionality, and subsequent backwards compatilbility. - - Will warn about deprecation on use. - - Args: - new_func: - New function to point to instead - - Example: - >>> def new_func(): # New function name - ... - >>> @BackwardsCompatibility(new_func) - >>> def old_func(*a, **kw): - ... - - """ - - def decorator(func: C) -> C: - def wrapped(*args, **kwargs): - warnings.warn( - f"{func.__name__} has been removed in favour of {new_func.__name__}, please switch over.", - DeprecationWarning, - ) - return new_func(*args, **kwargs) - - return wrapped - - return decorator From 957bd1ea7bcced314d5df34f42e3757e5ddeed91 Mon Sep 17 00:00:00 2001 From: Tennessee Leeuwenburg Date: Wed, 29 Apr 2026 20:16:45 +1000 Subject: [PATCH 2/2] Linting --- .../src/pyearthtools/pipeline/operations/xarray/reshape.py | 1 - packages/utils/src/pyearthtools/utils/decorators.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py b/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py index a427d83b..447afdb2 100644 --- a/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py +++ b/packages/pipeline/src/pyearthtools/pipeline/operations/xarray/reshape.py @@ -238,4 +238,3 @@ def apply_func(self, dataset: xr.Dataset) -> xr.Dataset | xr.DataArray: def undo_func(self, ds): return pyearthtools.pipeline.operations.xarray.reshape.CoordinateFlatten(self._coordinate)(ds) - diff --git a/packages/utils/src/pyearthtools/utils/decorators.py b/packages/utils/src/pyearthtools/utils/decorators.py index 8f35fd78..c7207a27 100644 --- a/packages/utils/src/pyearthtools/utils/decorators.py +++ b/packages/utils/src/pyearthtools/utils/decorators.py @@ -16,7 +16,6 @@ from __future__ import annotations import functools -import warnings from typing import Any, Callable, TypeVar C = TypeVar("C", bound=Callable[..., Any]) @@ -92,5 +91,3 @@ def wrapper(*args, **kwargs): return wrapper return internal_function - -