summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-20 09:32:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-20 09:32:05 +0000
commit8e34d9e75f42158fd0553a1583a38c64c373151c (patch)
tree97210524cb84512c477421e1950f2c6f7e1a3089
parentAdding upstream version 1.14.0. (diff)
downloadiredis-29a91b69f29c5e847e38d35d774086b363b4f321.tar.xz
iredis-29a91b69f29c5e847e38d35d774086b363b4f321.zip
Adding upstream version 1.14.1.upstream/1.14.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--.bumpversion.cfg2
-rw-r--r--.github/workflows/release.yaml4
-rw-r--r--.github/workflows/test-binary-build.yaml2
-rw-r--r--.github/workflows/test.yaml4
-rw-r--r--CHANGELOG.md5
-rw-r--r--README.md2
-rw-r--r--iredis/__init__.py2
-rw-r--r--iredis/client.py1
-rw-r--r--iredis/commands.py2
-rw-r--r--iredis/completers.py5
-rw-r--r--iredis/config.py6
-rw-r--r--iredis/entry.py1
-rw-r--r--iredis/markdown.py4
-rw-r--r--iredis/renders.py1
-rw-r--r--iredis/utils.py13
-rw-r--r--iredis/warning.py4
-rw-r--r--poetry.lock62
-rw-r--r--pyproject.toml5
-rw-r--r--tests/cli_tests/test_config.py2
-rw-r--r--tests/cli_tests/test_history.py4
-rw-r--r--tests/cli_tests/test_pager.py4
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/unittests/test_entry.py13
-rw-r--r--tests/unittests/test_utils.py1
24 files changed, 55 insertions, 96 deletions
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index 9ef25fa..57d8696 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 1.14.0
+current_version = 1.14.1
commit = True
tag = True
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 2e27a96..d8b20c1 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
- python-version: 3.7
+ python-version: 3.8
architecture: 'x64'
- name: Cache venv
uses: actions/cache@v1
@@ -77,7 +77,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
- python-version: 3.7
+ python-version: 3.8
architecture: 'x64'
- name: Cache venv
uses: actions/cache@v1
diff --git a/.github/workflows/test-binary-build.yaml b/.github/workflows/test-binary-build.yaml
index 11e720a..1fbcd80 100644
--- a/.github/workflows/test-binary-build.yaml
+++ b/.github/workflows/test-binary-build.yaml
@@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
- python-version: 3.7
+ python-version: 3.8
architecture: 'x64'
- name: Cache venv
uses: actions/cache@v1
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 9516dd9..feedaa5 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.7", "3.8", "3.9", "3.10", "3.11.1"]
+ python: ["3.8", "3.9", "3.10", "3.11.1"]
redis: [5, 6, 7, 7.2]
runs-on: ${{ matrix.os }}
@@ -65,7 +65,7 @@ jobs:
skip: ./docs/assets/demo.svg,./iredis/data/commands.json,./iredis/data/commands/*,./tests/unittests/*
- uses: actions/setup-python@v4
with:
- python-version: 3.7
+ python-version: 3.8
architecture: "x64"
- name: Cache venv
uses: actions/cache@v2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c98e9f2..7ee0f7d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
## UPCOMING
+### 1.14.1
+
+- Bugfix: fix argument parsing, `"foo\nbar"` will be parsed to `foo` and `\`
+ and `n` and `bar`, the `\` and `n` should be one character `\n` instead.
+
## 1.14
- Dependency: upgrade redis-py to 5 (thanks to [chayim])
diff --git a/README.md b/README.md
index 41927fc..826cb3d 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
<p align="center">
<a href="https://github.com/laixintao/iredis/actions"><img src="https://github.com/laixintao/iredis/workflows/Test/badge.svg" alt="Github Action"></a>
<a href="https://badge.fury.io/py/iredis"><img src="https://badge.fury.io/py/iredis.svg" alt="PyPI version"></a>
-<img src="https://badgen.net/badge/python/3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11" alt="Python version">
+<img src="https://badgen.net/badge/python/3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11" alt="Python version">
<a href="https://pepy.tech/project/iredis"><img src="https://pepy.tech/badge/iredis" alt="Download stats"></a>
</p>
diff --git a/iredis/__init__.py b/iredis/__init__.py
index b9f68ed..4454c8d 100644
--- a/iredis/__init__.py
+++ b/iredis/__init__.py
@@ -1 +1 @@
-__version__ = "1.14.0"
+__version__ = "1.14.1"
diff --git a/iredis/client.py b/iredis/client.py
index f7164b8..a952638 100644
--- a/iredis/client.py
+++ b/iredis/client.py
@@ -1,6 +1,7 @@
"""
IRedis client.
"""
+
import re
import os
import sys
diff --git a/iredis/commands.py b/iredis/commands.py
index cf21a54..3580cdb 100644
--- a/iredis/commands.py
+++ b/iredis/commands.py
@@ -120,7 +120,7 @@ def split_command_args(command):
# `command` with `args` is ('in') which is an invalid case.
normalized_input_command = " ".join(command.split()).upper()
if (
- re.search("\s", command)
+ re.search(r"\s", command)
and command_name.startswith(normalized_input_command)
and command_name != normalized_input_command
):
diff --git a/iredis/completers.py b/iredis/completers.py
index 6f9ecac..b17d3cc 100644
--- a/iredis/completers.py
+++ b/iredis/completers.py
@@ -139,8 +139,7 @@ class TimestampCompleter(Completer):
)
# here we yield bigger timestamp first.
- for completion in sorted(completions, key=lambda a: a.text):
- yield completion
+ yield from sorted(completions, key=lambda a: a.text)
class IRedisCompleter(Completer):
@@ -290,7 +289,7 @@ class IRedisCompleter(Completer):
self.key_completer.touch_words(ensure_str(items))
def __repr__(self) -> str:
- return "DynamicCompleter(%r -> %r)" % (
+ return "DynamicCompleter({!r} -> {!r})".format(
self.get_completer,
self.current_completer,
)
diff --git a/iredis/config.py b/iredis/config.py
index 4041bb6..7a54220 100644
--- a/iredis/config.py
+++ b/iredis/config.py
@@ -88,13 +88,13 @@ def read_config_file(f):
config = ConfigObj(f, interpolation=False, encoding="utf8")
except ConfigObjError as e:
logger.error(
- "Unable to parse line {0} of config file " "'{1}'.".format(e.line_number, f)
+ "Unable to parse line {} of config file " "'{}'.".format(e.line_number, f)
)
logger.error("Using successfully parsed config values.")
return e.config
- except (IOError, OSError) as e:
+ except OSError as e:
logger.error(
- "You don't have permission to read " "config file '{0}'.".format(e.filename)
+ "You don't have permission to read " "config file '{}'.".format(e.filename)
)
return None
diff --git a/iredis/entry.py b/iredis/entry.py
index 0799a07..b4615bb 100644
--- a/iredis/entry.py
+++ b/iredis/entry.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import os
import logging
import sys
diff --git a/iredis/markdown.py b/iredis/markdown.py
index 89297ec..a24b793 100644
--- a/iredis/markdown.py
+++ b/iredis/markdown.py
@@ -39,7 +39,7 @@ class TerminalRender(mistune.HTMLRenderer):
tag = "ul"
if ordered:
tag = "ol"
- return "<%s>%s</%s>\n" % (tag, body, tag)
+ return "<{}>{}</{}>\n".format(tag, body, tag)
def list_item(self, text, *args):
"""Rendering list item snippet. Like ``<li>``."""
@@ -62,5 +62,5 @@ def replace_to_markdown_title(original):
def render(text):
replaced = replace_to_markdown_title(text)
html_text = markdown_render(replaced)
- logger.debug("[Document] {} ...".format(html_text)[:20])
+ logger.debug(f"[Document] {html_text} ..."[:20])
return to_formatted_text(HTML(html_text))
diff --git a/iredis/renders.py b/iredis/renders.py
index d695407..9458263 100644
--- a/iredis/renders.py
+++ b/iredis/renders.py
@@ -4,6 +4,7 @@ This module will be auto loaded to callbacks.
func(redis-response) -> formatted result(str)
"""
+
import logging
import time
from packaging.version import parse as version_parse
diff --git a/iredis/utils.py b/iredis/utils.py
index 5a61425..aa00533 100644
--- a/iredis/utils.py
+++ b/iredis/utils.py
@@ -39,10 +39,11 @@ def literal_bytes(b):
return b
-def _valid_token(words):
- token = "".join(words).strip()
- if token:
- yield token
+def nappend(word, c, pre_back_slash):
+ if pre_back_slash and c == "n": # \n
+ word[-1] = "\n"
+ else:
+ word.append(c)
def strip_quote_args(s):
@@ -69,7 +70,7 @@ def strip_quote_args(s):
# previous char is \ , merge with current "
word[-1] = char
else:
- word.append(char)
+ nappend(word, char, pre_back_slash)
# not in quote
else:
# separator
@@ -81,7 +82,7 @@ def strip_quote_args(s):
elif char in ["'", '"']:
in_quote = char
else:
- word.append(char)
+ nappend(word, char, pre_back_slash)
if char == "\\" and not pre_back_slash:
pre_back_slash = True
else:
diff --git a/iredis/warning.py b/iredis/warning.py
index bb8231e..0217a29 100644
--- a/iredis/warning.py
+++ b/iredis/warning.py
@@ -1,7 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-
import sys
import click
from .commands import dangerous_commands
diff --git a/poetry.lock b/poetry.lock
index 752359a..73a4b58 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand.
[[package]]
name = "async-timeout"
@@ -11,9 +11,6 @@ files = [
{file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"},
]
-[package.dependencies]
-typing-extensions = {version = ">=3.6.5", markers = "python_version < \"3.8\""}
-
[[package]]
name = "click"
version = "8.1.7"
@@ -27,7 +24,6 @@ files = [
[package.dependencies]
colorama = {version = "*", markers = "platform_system == \"Windows\""}
-importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}
[[package]]
name = "colorama"
@@ -69,26 +65,6 @@ files = [
test = ["pytest (>=6)"]
[[package]]
-name = "importlib-metadata"
-version = "6.7.0"
-description = "Read metadata from Python packages"
-optional = false
-python-versions = ">=3.7"
-files = [
- {file = "importlib_metadata-6.7.0-py3-none-any.whl", hash = "sha256:cb52082e659e97afc5dac71e79de97d8681de3aa07ff18578330904a9d18e5b5"},
- {file = "importlib_metadata-6.7.0.tar.gz", hash = "sha256:1aaf550d4f73e5d6783e7acb77aec43d49da8017410afae93822cc9cca98c4d4"},
-]
-
-[package.dependencies]
-typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""}
-zipp = ">=0.5"
-
-[package.extras]
-docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"]
-perf = ["ipython"]
-testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"]
-
-[[package]]
name = "iniconfig"
version = "2.0.0"
description = "brain-dead simple config-ini parsing"
@@ -180,9 +156,6 @@ files = [
{file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"},
]
-[package.dependencies]
-importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
-
[package.extras]
dev = ["pre-commit", "tox"]
testing = ["pytest", "pytest-benchmark"]
@@ -240,7 +213,6 @@ files = [
[package.dependencies]
colorama = {version = "*", markers = "sys_platform == \"win32\""}
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
-importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
iniconfig = "*"
packaging = "*"
pluggy = ">=0.12,<2.0"
@@ -287,8 +259,6 @@ files = [
[package.dependencies]
async-timeout = {version = ">=4.0.2", markers = "python_full_version <= \"3.11.2\""}
-importlib-metadata = {version = ">=1.0", markers = "python_version < \"3.8\""}
-typing-extensions = {version = "*", markers = "python_version < \"3.8\""}
[package.extras]
hiredis = ["hiredis (>=1.0.0)"]
@@ -317,17 +287,6 @@ files = [
]
[[package]]
-name = "typing-extensions"
-version = "4.7.1"
-description = "Backported and Experimental Type Hints for Python 3.7+"
-optional = false
-python-versions = ">=3.7"
-files = [
- {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"},
- {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"},
-]
-
-[[package]]
name = "wcwidth"
version = "0.1.9"
description = "Measures number of Terminal column cells of wide-character codes"
@@ -338,22 +297,7 @@ files = [
{file = "wcwidth-0.1.9.tar.gz", hash = "sha256:ee73862862a156bf77ff92b09034fc4825dd3af9cf81bc5b360668d425f3c5f1"},
]
-[[package]]
-name = "zipp"
-version = "3.15.0"
-description = "Backport of pathlib-compatible object wrapper for zip files"
-optional = false
-python-versions = ">=3.7"
-files = [
- {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"},
- {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"},
-]
-
-[package.extras]
-docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"]
-testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"]
-
[metadata]
lock-version = "2.0"
-python-versions = "^3.7"
-content-hash = "33eaaf0e62340be5fa5c74233fd0760e61c9635cbad8f38d625f3c253fb9df4c"
+python-versions = "^3.8"
+content-hash = "6237a8e8d2a29bc969f11386bfb6b7fca4006212b57e91f3e120cc7353e36e55"
diff --git a/pyproject.toml b/pyproject.toml
index 088fb45..bc2e5d4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "iredis"
-version = "1.14.0"
+version = "1.14.1"
description = "Terminal client for Redis with auto-completion and syntax highlighting."
authors = ["laixintao <laixintao1995@163.com>"]
readme = 'README.md'
@@ -15,7 +15,6 @@ classifiers = [
"Environment :: Console :: Curses",
"Environment :: MacOS X",
"Operating System :: OS Independent",
- "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
@@ -31,7 +30,7 @@ packages = [
]
[tool.poetry.dependencies]
-python = "^3.7"
+python = "^3.8"
prompt_toolkit = "^3"
Pygments = "^2"
mistune = "^3.0"
diff --git a/tests/cli_tests/test_config.py b/tests/cli_tests/test_config.py
index 1795c62..eeaba33 100644
--- a/tests/cli_tests/test_config.py
+++ b/tests/cli_tests/test_config.py
@@ -19,7 +19,7 @@ def test_log_location_config():
log = Path("/tmp/iredis1.log")
assert log.exists()
- with open(log, "r") as logfile:
+ with open(log) as logfile:
content = logfile.read()
assert len(content) > 100
diff --git a/tests/cli_tests/test_history.py b/tests/cli_tests/test_history.py
index 09e6c82..acb25d3 100644
--- a/tests/cli_tests/test_history.py
+++ b/tests/cli_tests/test_history.py
@@ -10,7 +10,7 @@ def test_history_not_log_auth(cli):
cli.sendline("set foo bar")
cli.expect("OK")
- with open(os.path.expanduser("~/.iredis_history"), "r") as history_file:
+ with open(os.path.expanduser("~/.iredis_history")) as history_file:
content = history_file.read()
assert "set foo bar" in content
@@ -36,7 +36,7 @@ def test_history_create_and_writing_with_config():
log = Path("/tmp/iredis_history.txt")
assert log.exists()
- with open(log, "r") as logfile:
+ with open(log) as logfile:
content = logfile.read()
assert "set hello world" in content
diff --git a/tests/cli_tests/test_pager.py b/tests/cli_tests/test_pager.py
index c3f9fb0..e8106a4 100644
--- a/tests/cli_tests/test_pager.py
+++ b/tests/cli_tests/test_pager.py
@@ -13,12 +13,12 @@ TEST_IREDISRC = "/tmp/.iredisrc.test"
TEST_PAGER_BOUNDARY = "---boundary---"
TEST_PAGER_BOUNDARY_NUMBER = "---88938347271---"
-env_pager = "{0} {1} {2}".format(
+env_pager = "{} {} {}".format(
sys.executable,
os.path.join(pathlib.Path(__file__).parent, "wrappager.py"),
TEST_PAGER_BOUNDARY,
)
-env_pager_numbers = "{0} {1} {2}".format(
+env_pager_numbers = "{} {} {}".format(
sys.executable,
os.path.join(pathlib.Path(__file__).parent, "wrappager.py"),
TEST_PAGER_BOUNDARY_NUMBER,
diff --git a/tests/conftest.py b/tests/conftest.py
index 593e8a8..42840e3 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -53,7 +53,7 @@ def judge_command():
return
variables = m.variables()
- print("Found variables: {}".format(variables))
+ print(f"Found variables: {variables}")
for expect_token, expect_value in expect.items():
all_variables = variables.getall(expect_token)
if len(all_variables) > 1:
diff --git a/tests/unittests/test_entry.py b/tests/unittests/test_entry.py
index e53861e..99d6931 100644
--- a/tests/unittests/test_entry.py
+++ b/tests/unittests/test_entry.py
@@ -175,6 +175,19 @@ def test_command_shell_options_higher_priority():
),
),
(
+ "redis://username:pass@word@localhost:12345/2",
+ DSN(
+ scheme="redis",
+ host="localhost",
+ port=12345,
+ path=None,
+ db=2,
+ username="username",
+ password="pass@word",
+ verify_ssl=None,
+ ),
+ ),
+ (
"redis://username@localhost:12345",
DSN(
scheme="redis",
diff --git a/tests/unittests/test_utils.py b/tests/unittests/test_utils.py
index 98ea8db..e00eaff 100644
--- a/tests/unittests/test_utils.py
+++ b/tests/unittests/test_utils.py
@@ -55,6 +55,7 @@ def test_timer():
(r'""', [""]), # set foo "" is a legal command
(r"\\", ["\\\\"]), # backslash are legal
("\\hello\\", ["\\hello\\"]), # backslash are legal
+ ('foo "bar\\n1"', ["foo", "bar\n1"]),
],
)
def test_stripe_quote_escape_in_quote(test_input, expected):