Skip to content

Commit

Permalink
Remove deprecated datetime functions (#1134)
Browse files Browse the repository at this point in the history
* Remove deprecated datetime functions

* remove all usage of deprecated methods

* readd utcnow filter because of boto3
  • Loading branch information
hussein-awala authored Nov 19, 2024
1 parent 7ecfa71 commit 5f0f770
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pyiceberg/table/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.
from __future__ import annotations

from datetime import datetime
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple

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

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

history.append({
"made_current_at": datetime.utcfromtimestamp(snapshot_entry.timestamp_ms / 1000.0),
"made_current_at": datetime.fromtimestamp(snapshot_entry.timestamp_ms / 1000.0, tz=timezone.utc),
"snapshot_id": snapshot_entry.snapshot_id,
"parent_id": snapshot.parent_snapshot_id if snapshot else None,
"is_current_ancestor": snapshot_entry.snapshot_id in ancestors_ids,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +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 once https://github.com/boto/boto3/issues/3889 is fixed.
"ignore:datetime.datetime.utcnow\\(\\) is deprecated and scheduled for removal in a future version.",
"ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated and scheduled for removal in a future version.",
]

[tool.black]
Expand Down

0 comments on commit 5f0f770

Please sign in to comment.