Skip to content

Commit

Permalink
remove pendulum
Browse files Browse the repository at this point in the history
  • Loading branch information
deronnax committed Apr 11, 2024
1 parent c0992a0 commit 8087e8e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 73 deletions.
8 changes: 4 additions & 4 deletions iredis/completers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import Iterable

import pendulum
from datetime import datetime
from prompt_toolkit.completion import (
CompleteEvent,
Completer,
Expand Down Expand Up @@ -102,7 +102,7 @@ def _completion_humanize_time(self, document: Document) -> Iterable[Completion]:
if not text.isnumeric():
return
current = int(text)
now = pendulum.now()
now = datetime.now()
for unit, minimum in self.when_lower_than.items():
if current <= minimum:
if self.future_time:
Expand All @@ -122,11 +122,11 @@ def _completion_humanize_time(self, document: Document) -> Iterable[Completion]:
def _completion_formatted_time(self, document: Document) -> Iterable[Completion]:
text = document.text
try:
dt = pendulum.parse(text)
dt = datetime.fromisoformat(text)
except Exception:
return
yield Completion(
str(dt.int_timestamp * self.factor),
str(dt.timestamp() * self.factor),
start_position=-len(document.text_before_cursor),
display_meta=str(dt),
)
Expand Down
63 changes: 2 additions & 61 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Pygments = "^2"
mistune = "^3.0"
configobj = "^5.0"
click = "^8.0"
pendulum = "^2.1.0"
# wcwidth 0.2.x uses pkg_resources which is not supported by PyOxidizer
wcwidth = "0.1.9"
packaging = "^23.0"
Expand Down
14 changes: 7 additions & 7 deletions tests/unittests/test_completers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime
from unittest.mock import MagicMock, patch

import pendulum
from prompt_toolkit.formatted_text import FormattedText
from prompt_toolkit.completion import Completion

Expand Down Expand Up @@ -180,9 +180,9 @@ def test_group_completer():
]


@patch("iredis.completers.pendulum.now")
@patch("iredis.completers.datetime.now")
def test_timestamp_completer_humanize_time_completion(fake_now):
fake_now.return_value = pendulum.from_timestamp(1578487013)
fake_now.return_value = datetime.fromtimestamp(1578487013)
c = TimestampCompleter(is_milliseconds=True, future_time=False)

fake_document = MagicMock()
Expand Down Expand Up @@ -260,9 +260,9 @@ def test_timestamp_completer_humanize_time_completion(fake_now):
]


@patch("iredis.completers.pendulum.now")
@patch("iredis.completers.datetime.now")
def test_timestamp_completer_humanize_time_completion_seconds(fake_now):
fake_now.return_value = pendulum.from_timestamp(1578487013)
fake_now.return_value = datetime.fromtimestamp(1578487013)
c = TimestampCompleter(is_milliseconds=False, future_time=False)

fake_document = MagicMock()
Expand Down Expand Up @@ -297,9 +297,9 @@ def test_timestamp_completer_humanize_time_completion_seconds(fake_now):
]


@patch("iredis.completers.pendulum.now")
@patch("iredis.completers.datetime.now")
def test_timestamp_completer_humanize_time_completion_seconds_future_time(fake_now):
fake_now.return_value = pendulum.from_timestamp(1578487013)
fake_now.return_value = datetime.fromtimestamp(1578487013)
c = TimestampCompleter(is_milliseconds=False, future_time=True)

fake_document = MagicMock()
Expand Down

0 comments on commit 8087e8e

Please sign in to comment.