Skip to content

Commit

Permalink
dont override global warning (#1350)
Browse files Browse the repository at this point in the history
* dont override global

* add back warning filter
  • Loading branch information
kevinjqliu authored Nov 20, 2024
1 parent 12e87a4 commit 8e0e6a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pyiceberg/utils/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,8 @@ filterwarnings = [
"ignore:unclosed <socket.socket",
# Remove this in a future release of PySpark.
"ignore:distutils Version classes are deprecated. Use packaging.version instead.",
# Remove this in a future release of PySpark. https://github.com/apache/iceberg-python/issues/1349
"ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated and scheduled for removal in a future version.",
# Remove this once https://github.com/boto/boto3/issues/3889 is fixed.
"ignore:datetime.datetime.utcnow\\(\\) is deprecated and scheduled for removal in a future version.",
]
Expand Down

0 comments on commit 8e0e6a1

Please sign in to comment.