From 152f636a734d306e3b6eeb60f9c8027a47a319f1 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 97aca6c128..14f4163c4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -909,6 +909,8 @@ filterwarnings = [ "ignore:unclosed