From 8e0e6a1a17a68eb980f64ddb6730b9d63846ba18 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Wed, 20 Nov 2024 15:46:05 -0500 Subject: [PATCH] dont override global warning (#1350) * dont override global * add back warning filter --- pyiceberg/utils/deprecated.py | 15 +++++++-------- pyproject.toml | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pyiceberg/utils/deprecated.py b/pyiceberg/utils/deprecated.py index 188d0ce68b..da2cb3b500 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 09461ccd2f..4947571345 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -903,6 +903,8 @@ filterwarnings = [ "ignore:unclosed