diff --git a/iredis/completers.py b/iredis/completers.py index b17d3cc5..b901fa6b 100644 --- a/iredis/completers.py +++ b/iredis/completers.py @@ -1,7 +1,7 @@ import logging from typing import Iterable -import pendulum +from datetime import datetime from prompt_toolkit.completion import ( CompleteEvent, Completer, @@ -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: @@ -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), ) diff --git a/poetry.lock b/poetry.lock index 73a4b58b..a35c63df 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "async-timeout" @@ -97,40 +97,6 @@ files = [ {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, ] -[[package]] -name = "pendulum" -version = "2.1.2" -description = "Python datetimes made easy" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -files = [ - {file = "pendulum-2.1.2-cp27-cp27m-macosx_10_15_x86_64.whl", hash = "sha256:b6c352f4bd32dff1ea7066bd31ad0f71f8d8100b9ff709fb343f3b86cee43efe"}, - {file = "pendulum-2.1.2-cp27-cp27m-win_amd64.whl", hash = "sha256:318f72f62e8e23cd6660dbafe1e346950281a9aed144b5c596b2ddabc1d19739"}, - {file = "pendulum-2.1.2-cp35-cp35m-macosx_10_15_x86_64.whl", hash = "sha256:0731f0c661a3cb779d398803655494893c9f581f6488048b3fb629c2342b5394"}, - {file = "pendulum-2.1.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:3481fad1dc3f6f6738bd575a951d3c15d4b4ce7c82dce37cf8ac1483fde6e8b0"}, - {file = "pendulum-2.1.2-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9702069c694306297ed362ce7e3c1ef8404ac8ede39f9b28b7c1a7ad8c3959e3"}, - {file = "pendulum-2.1.2-cp35-cp35m-win_amd64.whl", hash = "sha256:fb53ffa0085002ddd43b6ca61a7b34f2d4d7c3ed66f931fe599e1a531b42af9b"}, - {file = "pendulum-2.1.2-cp36-cp36m-macosx_10_15_x86_64.whl", hash = "sha256:c501749fdd3d6f9e726086bf0cd4437281ed47e7bca132ddb522f86a1645d360"}, - {file = "pendulum-2.1.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:c807a578a532eeb226150d5006f156632df2cc8c5693d778324b43ff8c515dd0"}, - {file = "pendulum-2.1.2-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:2d1619a721df661e506eff8db8614016f0720ac171fe80dda1333ee44e684087"}, - {file = "pendulum-2.1.2-cp36-cp36m-win_amd64.whl", hash = "sha256:f888f2d2909a414680a29ae74d0592758f2b9fcdee3549887779cd4055e975db"}, - {file = "pendulum-2.1.2-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:e95d329384717c7bf627bf27e204bc3b15c8238fa8d9d9781d93712776c14002"}, - {file = "pendulum-2.1.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:4c9c689747f39d0d02a9f94fcee737b34a5773803a64a5fdb046ee9cac7442c5"}, - {file = "pendulum-2.1.2-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:1245cd0075a3c6d889f581f6325dd8404aca5884dea7223a5566c38aab94642b"}, - {file = "pendulum-2.1.2-cp37-cp37m-win_amd64.whl", hash = "sha256:db0a40d8bcd27b4fb46676e8eb3c732c67a5a5e6bfab8927028224fbced0b40b"}, - {file = "pendulum-2.1.2-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:f5e236e7730cab1644e1b87aca3d2ff3e375a608542e90fe25685dae46310116"}, - {file = "pendulum-2.1.2-cp38-cp38-manylinux1_i686.whl", hash = "sha256:de42ea3e2943171a9e95141f2eecf972480636e8e484ccffaf1e833929e9e052"}, - {file = "pendulum-2.1.2-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7c5ec650cb4bec4c63a89a0242cc8c3cebcec92fcfe937c417ba18277d8560be"}, - {file = "pendulum-2.1.2-cp38-cp38-win_amd64.whl", hash = "sha256:33fb61601083f3eb1d15edeb45274f73c63b3c44a8524703dc143f4212bf3269"}, - {file = "pendulum-2.1.2-cp39-cp39-manylinux1_i686.whl", hash = "sha256:29c40a6f2942376185728c9a0347d7c0f07905638c83007e1d262781f1e6953a"}, - {file = "pendulum-2.1.2-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:94b1fc947bfe38579b28e1cccb36f7e28a15e841f30384b5ad6c5e31055c85d7"}, - {file = "pendulum-2.1.2.tar.gz", hash = "sha256:b06a0ca1bfe41c990bbf0c029f0b6501a7f2ec4e38bfec730712015e8860f207"}, -] - -[package.dependencies] -python-dateutil = ">=2.6,<3.0" -pytzdata = ">=2020.1" - [[package]] name = "pexpect" version = "4.8.0" @@ -221,31 +187,6 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] -[[package]] -name = "python-dateutil" -version = "2.8.2" -description = "Extensions to the standard Python datetime module" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -files = [ - {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, - {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, -] - -[package.dependencies] -six = ">=1.5" - -[[package]] -name = "pytzdata" -version = "2020.1" -description = "The Olson timezone database for Python." -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -files = [ - {file = "pytzdata-2020.1-py2.py3-none-any.whl", hash = "sha256:e1e14750bcf95016381e4d472bad004eef710f2d6417240904070b3d6654485f"}, - {file = "pytzdata-2020.1.tar.gz", hash = "sha256:3efa13b335a00a8de1d345ae41ec78dd11c9f8807f522d39850f2dd828681540"}, -] - [[package]] name = "redis" version = "5.0.1" @@ -300,4 +241,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "6237a8e8d2a29bc969f11386bfb6b7fca4006212b57e91f3e120cc7353e36e55" +content-hash = "93c9be80f8691b1d7c0f48e0a350454f1ca8d0bb0270d82141e3e4d5a96dce51" diff --git a/pyproject.toml b/pyproject.toml index bc2e5d43..6fd41790 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/tests/unittests/test_completers.py b/tests/unittests/test_completers.py index 5441b0ee..41927619 100644 --- a/tests/unittests/test_completers.py +++ b/tests/unittests/test_completers.py @@ -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 @@ -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() @@ -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() @@ -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()