Skip to content

Commit

Permalink
Use custom warning (ParameterDeprecationWarning)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
milanbalazs committed Jan 18, 2024
1 parent ccd433d commit 46f3c0f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions podman/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 46f3c0f

Please sign in to comment.