Skip to content

Commit 5f0f770

Browse files
Remove deprecated datetime functions (#1134)
* Remove deprecated datetime functions * remove all usage of deprecated methods * readd utcnow filter because of boto3
1 parent 7ecfa71 commit 5f0f770

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pyiceberg/table/inspect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717
from __future__ import annotations
1818

19-
from datetime import datetime
19+
from datetime import datetime, timezone
2020
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple
2121

2222
from pyiceberg.conversions import from_bytes
@@ -76,7 +76,7 @@ def snapshots(self) -> "pa.Table":
7676
additional_properties = None
7777

7878
snapshots.append({
79-
"committed_at": datetime.utcfromtimestamp(snapshot.timestamp_ms / 1000.0),
79+
"committed_at": datetime.fromtimestamp(snapshot.timestamp_ms / 1000.0, tz=timezone.utc),
8080
"snapshot_id": snapshot.snapshot_id,
8181
"parent_id": snapshot.parent_snapshot_id,
8282
"operation": str(operation),
@@ -465,7 +465,7 @@ def history(self) -> "pa.Table":
465465
snapshot = metadata.snapshot_by_id(snapshot_entry.snapshot_id)
466466

467467
history.append({
468-
"made_current_at": datetime.utcfromtimestamp(snapshot_entry.timestamp_ms / 1000.0),
468+
"made_current_at": datetime.fromtimestamp(snapshot_entry.timestamp_ms / 1000.0, tz=timezone.utc),
469469
"snapshot_id": snapshot_entry.snapshot_id,
470470
"parent_id": snapshot.parent_snapshot_id if snapshot else None,
471471
"is_current_ancestor": snapshot_entry.snapshot_id in ancestors_ids,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,8 +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 once https://github.com/boto/boto3/issues/3889 is fixed.
906907
"ignore:datetime.datetime.utcnow\\(\\) is deprecated and scheduled for removal in a future version.",
907-
"ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated and scheduled for removal in a future version.",
908908
]
909909

910910
[tool.black]

0 commit comments

Comments
 (0)