Skip to content

Commit c4cd814

Browse files
committed
Deprecate old names for Errors
1 parent 1e0aeb9 commit c4cd814

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/blueapi/client/rest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,24 @@ def _request_and_deserialize(
267267
raise NoContentError(target_type)
268268
deserialized = TypeAdapter(target_type).validate_python(response.json())
269269
return deserialized
270+
271+
272+
# https://github.com/DiamondLightSource/blueapi/issues/1256 - remove before 2.0
273+
def __getattr__(name: str):
274+
import warnings
275+
276+
renames = {
277+
"UnauthorisedAccess": UnauthorisedAccessError,
278+
"NoContent": NoContentError,
279+
"InvalidParameters": InvalidParametersError,
280+
}
281+
rename = renames.get(name)
282+
if rename is not None:
283+
warnings.warn(
284+
DeprecationWarning(
285+
f"{name!r} is deprecated, use {rename.__name__!r} instead"
286+
),
287+
stacklevel=2,
288+
)
289+
return rename
290+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

src/blueapi/config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,22 @@ def load(self) -> C:
323323

324324
class MissingStompConfigurationError(Exception):
325325
pass
326+
327+
328+
# https://github.com/DiamondLightSource/blueapi/issues/1256 - remove before 2.0
329+
def __getattr__(name: str):
330+
import warnings
331+
332+
renames = {
333+
"MissingStompConfiguration": MissingStompConfigurationError,
334+
}
335+
rename = renames.get(name)
336+
if rename is not None:
337+
warnings.warn(
338+
DeprecationWarning(
339+
f"{name!r} is deprecated, use {rename.__name__!r} instead"
340+
),
341+
stacklevel=2,
342+
)
343+
return rename
344+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

0 commit comments

Comments
 (0)