From 46f3c0f002fc0f00bdd94985d2ba31856aa640a4 Mon Sep 17 00:00:00 2001 From: Milan Balazs Date: Thu, 18 Jan 2024 12:00:35 +0100 Subject: [PATCH] Use custom warning (ParameterDeprecationWarning) With this custom warning class only the specific warning will be shown to user (warnings.simplefilter). It doesn't affect to other Warings in other modules. Signed-off-by: Milan Balazs --- podman/api/client.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/podman/api/client.py b/podman/api/client.py index 3cd52637..7a98669b 100644 --- a/podman/api/client.py +++ b/podman/api/client.py @@ -28,8 +28,15 @@ _Timeout = Union[None, float, Tuple[float, float], Tuple[float, None]] """Type alias for request timeout parameter.""" -# Make the DeprecationWarning visible for user. -warnings.simplefilter('always', DeprecationWarning) + +class ParameterDeprecationWarning(DeprecationWarning): + """ + Custom DeprecationWarning for deprecated parameters. + """ + + +# Make the ParameterDeprecationWarning visible for user. +warnings.simplefilter('always', ParameterDeprecationWarning) class APIResponse: @@ -134,7 +141,7 @@ def __init__( if max_pools_size is not None: warnings.warn( "'max_pools_size' parameter is deprecated! Please use 'max_pool_size' parameter.", - DeprecationWarning, + ParameterDeprecationWarning, ) if max_pool_size is not None: raise ValueError(