Skip to content

Commit c7af1ce

Browse files
kevinjqliusungwy
authored andcommitted
dont override global warning (apache#1350)
* dont override global * add back warning filter
1 parent e1f73ec commit c7af1ce

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pyiceberg/utils/deprecated.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ def deprecation_message(deprecated_in: str, removed_in: str, help_message: Optio
5555

5656

5757
def _deprecation_warning(message: str) -> None:
58-
warnings.simplefilter("always", DeprecationWarning) # turn off filter
59-
60-
warnings.warn(
61-
message,
62-
category=DeprecationWarning,
63-
stacklevel=2,
64-
)
65-
warnings.simplefilter("default", DeprecationWarning) # reset filter
58+
with warnings.catch_warnings(): # temporarily override warning handling
59+
warnings.simplefilter("always", DeprecationWarning) # turn off filter
60+
warnings.warn(
61+
message,
62+
category=DeprecationWarning,
63+
stacklevel=2,
64+
)

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ filterwarnings = [
903903
"ignore:unclosed <socket.socket",
904904
# Remove this in a future release of PySpark.
905905
"ignore:distutils Version classes are deprecated. Use packaging.version instead.",
906+
# Remove this in a future release of PySpark. https://github.com/apache/iceberg-python/issues/1349
907+
"ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated and scheduled for removal in a future version.",
906908
# Remove this once https://github.com/boto/boto3/issues/3889 is fixed.
907909
"ignore:datetime.datetime.utcnow\\(\\) is deprecated and scheduled for removal in a future version.",
908910
]

0 commit comments

Comments
 (0)