diff options
Diffstat (limited to '')
-rw-r--r-- | .bumpversion.cfg | 2 | ||||
-rw-r--r-- | .github/workflows/test.yaml | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 7 | ||||
-rw-r--r-- | iredis/__init__.py | 2 | ||||
-rw-r--r-- | iredis/commands.py | 2 | ||||
-rw-r--r-- | iredis/completers.py | 17 | ||||
-rw-r--r-- | poetry.lock | 69 | ||||
-rw-r--r-- | pyproject.toml | 9 | ||||
-rw-r--r-- | tests/unittests/test_completers.py | 21 |
9 files changed, 54 insertions, 77 deletions
diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 57d8696..210a124 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.14.1 +current_version = 1.15.0 commit = True tag = True diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index feedaa5..6fb30ca 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-20.04"] - python: ["3.8", "3.9", "3.10", "3.11.1"] + python: ["3.8", "3.9", "3.10", "3.11.1", "3.12"] redis: [5, 6, 7, 7.2] runs-on: ${{ matrix.os }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ee0f7d..76d4c4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## UPCOMING +## 1.15 + +- Dependency: remove pendulum, add `python-dateutil` (thanks to [deronnax]) +- Dependency: Supports Python 3.12 Now! (thanks to [deronnax]) + + ### 1.14.1 - Bugfix: fix argument parsing, `"foo\nbar"` will be parsed to `foo` and `\` @@ -332,3 +338,4 @@ [aymericbeaumet]: https://github.com/aymericbeaumet [torrefatto]: https://github.com/torrefatto [chayim]: https://github.com/chayim +[deronnax]: https://github.com/deronnax diff --git a/iredis/__init__.py b/iredis/__init__.py index 4454c8d..6b0872c 100644 --- a/iredis/__init__.py +++ b/iredis/__init__.py @@ -1 +1 @@ -__version__ = "1.14.1" +__version__ = "1.15.0" diff --git a/iredis/commands.py b/iredis/commands.py index 3580cdb..481fc74 100644 --- a/iredis/commands.py +++ b/iredis/commands.py @@ -115,7 +115,7 @@ def split_command_args(command): command = command.strip() for command_name in all_commands: - # for command that is paritaly input, like `command in`, we should + # for command that is partially input, like `command in`, we should # match with `command info`, otherwise, `command in` will result in # `command` with `args` is ('in') which is an invalid case. normalized_input_command = " ".join(command.split()).upper() diff --git a/iredis/completers.py b/iredis/completers.py index b17d3cc..b412010 100644 --- a/iredis/completers.py +++ b/iredis/completers.py @@ -1,7 +1,8 @@ import logging from typing import Iterable +from datetime import datetime, timezone -import pendulum +from dateutil.relativedelta import relativedelta from prompt_toolkit.completion import ( CompleteEvent, Completer, @@ -102,19 +103,19 @@ class TimestampCompleter(Completer): 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: - dt = now.add(**{f"{unit}s": current}) + dt = now + relativedelta(**{f"{unit}s": current}) offset_text = "later" else: - dt = now.subtract(**{f"{unit}s": current}) + dt = now - relativedelta(**{f"{unit}s": current}) offset_text = "ago" - meta = f"{text} {unit}{'s' if current > 1 else ''} {offset_text} ({dt.format('YYYY-MM-DD HH:mm:ss')})" + meta = f"{text} {unit}{'s' if current > 1 else ''} {offset_text} ({dt.strftime('%Y-%m-%d %H:%M:%S')})" yield Completion( - str(dt.int_timestamp * self.factor), + str(int(dt.timestamp()) * self.factor), start_position=-len(document.text_before_cursor), display_meta=meta, ) @@ -122,11 +123,11 @@ class TimestampCompleter(Completer): def _completion_formatted_time(self, document: Document) -> Iterable[Completion]: text = document.text try: - dt = pendulum.parse(text) + dt = datetime.fromisoformat(text).replace(tzinfo=timezone.utc) except Exception: return yield Completion( - str(dt.int_timestamp * self.factor), + str(int(dt.timestamp()) * self.factor), start_position=-len(document.text_before_cursor), display_meta=str(dt), ) diff --git a/poetry.lock b/poetry.lock index 73a4b58..5f872e9 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" @@ -65,6 +65,20 @@ files = [ test = ["pytest (>=6)"] [[package]] +name = "freezegun" +version = "1.4.0" +description = "Let your Python tests travel through time" +optional = false +python-versions = ">=3.7" +files = [ + {file = "freezegun-1.4.0-py3-none-any.whl", hash = "sha256:55e0fc3c84ebf0a96a5aa23ff8b53d70246479e9a68863f1fcac5a3e52f19dd6"}, + {file = "freezegun-1.4.0.tar.gz", hash = "sha256:10939b0ba0ff5adaecf3b06a5c2f73071d9678e507c5eaedb23c761d56ac774b"}, +] + +[package.dependencies] +python-dateutil = ">=2.7" + +[[package]] name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" @@ -98,40 +112,6 @@ files = [ ] [[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" description = "Pexpect allows easy control of interactive console applications." @@ -223,30 +203,19 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no [[package]] name = "python-dateutil" -version = "2.8.2" +version = "2.9.0.post0" 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"}, + {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, + {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, ] [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" description = "Python client for Redis database and key-value store" @@ -300,4 +269,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "6237a8e8d2a29bc969f11386bfb6b7fca4006212b57e91f3e120cc7353e36e55" +content-hash = "8d61935e62f875626767931b48590feeb249271f59d861ea24c74019a32a5fed" diff --git a/pyproject.toml b/pyproject.toml index bc2e5d4..38c3e8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "iredis" -version = "1.14.1" +version = "1.15.0" description = "Terminal client for Redis with auto-completion and syntax highlighting." authors = ["laixintao <laixintao1995@163.com>"] readme = 'README.md' @@ -19,7 +19,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", - # "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.12", "Topic :: Database", "License :: OSI Approved :: MIT License", "Intended Audience :: Developers", @@ -36,11 +36,11 @@ 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" redis = "^5.0.0" +python-dateutil = "^2.8.2" [tool.poetry.dev-dependencies] pytest = "^7.2" @@ -49,6 +49,9 @@ pexpect = "^4.7" [tool.poetry.scripts] iredis = 'iredis.entry:main' +[tool.poetry.group.dev.dependencies] +freezegun = "^1.4.0" + [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" diff --git a/tests/unittests/test_completers.py b/tests/unittests/test_completers.py index 5441b0e..71f0234 100644 --- a/tests/unittests/test_completers.py +++ b/tests/unittests/test_completers.py @@ -1,6 +1,6 @@ -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock -import pendulum +from freezegun import freeze_time from prompt_toolkit.formatted_text import FormattedText from prompt_toolkit.completion import Completion @@ -180,9 +180,8 @@ def test_group_completer(): ] -@patch("iredis.completers.pendulum.now") -def test_timestamp_completer_humanize_time_completion(fake_now): - fake_now.return_value = pendulum.from_timestamp(1578487013) +@freeze_time("2020-01-08 12:36:53") +def test_timestamp_completer_humanize_time_completion(): c = TimestampCompleter(is_milliseconds=True, future_time=False) fake_document = MagicMock() @@ -260,9 +259,8 @@ def test_timestamp_completer_humanize_time_completion(fake_now): ] -@patch("iredis.completers.pendulum.now") -def test_timestamp_completer_humanize_time_completion_seconds(fake_now): - fake_now.return_value = pendulum.from_timestamp(1578487013) +@freeze_time("2020-01-08 12:36:53") +def test_timestamp_completer_humanize_time_completion_seconds(): c = TimestampCompleter(is_milliseconds=False, future_time=False) fake_document = MagicMock() @@ -297,9 +295,8 @@ def test_timestamp_completer_humanize_time_completion_seconds(fake_now): ] -@patch("iredis.completers.pendulum.now") -def test_timestamp_completer_humanize_time_completion_seconds_future_time(fake_now): - fake_now.return_value = pendulum.from_timestamp(1578487013) +@freeze_time("2020-01-08 12:36:53") +def test_timestamp_completer_humanize_time_completion_seconds_future_time(): c = TimestampCompleter(is_milliseconds=False, future_time=True) fake_document = MagicMock() @@ -350,7 +347,7 @@ def test_timestamp_completer_datetime_format_time_completion(): text="1581033600000", start_position=-10, display=FormattedText([("", "1581033600000")]), - display_meta="2020-02-07T00:00:00+00:00", + display_meta="2020-02-07 00:00:00+00:00", ) ] |