diff --git a/pyiceberg/utils/deprecated.py b/pyiceberg/utils/deprecated.py index 188d0ce68..da2cb3b50 100644 --- a/pyiceberg/utils/deprecated.py +++ b/pyiceberg/utils/deprecated.py @@ -55,11 +55,10 @@ def deprecation_message(deprecated_in: str, removed_in: str, help_message: Optio def _deprecation_warning(message: str) -> None: - warnings.simplefilter("always", DeprecationWarning) # turn off filter - - warnings.warn( - message, - category=DeprecationWarning, - stacklevel=2, - ) - warnings.simplefilter("default", DeprecationWarning) # reset filter + with warnings.catch_warnings(): # temporarily override warning handling + warnings.simplefilter("always", DeprecationWarning) # turn off filter + warnings.warn( + message, + category=DeprecationWarning, + stacklevel=2, + ) diff --git a/pyproject.toml b/pyproject.toml index 09461ccd2..494757134 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -903,6 +903,8 @@ filterwarnings = [ "ignore:unclosed