Skip to content

Commit

Permalink
Merge branch 'master' into add-python-3.12-support
Browse files Browse the repository at this point in the history
  • Loading branch information
deronnax committed Apr 11, 2024
2 parents 3c9dc27 + c0992a0 commit 86fa7fe
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.14.0
current_version = 1.14.1
commit = True
tag = True

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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])
Expand Down
2 changes: 1 addition & 1 deletion iredis/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.14.0"
__version__ = "1.14.1"
1 change: 1 addition & 0 deletions iredis/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
IRedis client.
"""

import re
import os
import sys
Expand Down
5 changes: 2 additions & 3 deletions iredis/completers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ def get_completions(
)

# 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):
Expand Down Expand Up @@ -290,7 +289,7 @@ def _touch_keys(self, items):
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,
)
Expand Down
6 changes: 3 additions & 3 deletions iredis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion iredis/entry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import logging
import sys
Expand Down
4 changes: 2 additions & 2 deletions iredis/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def list(self, body, ordered, *args, **kwargs):
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>``."""
Expand All @@ -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))
1 change: 1 addition & 0 deletions iredis/renders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
func(redis-response) -> formatted result(str)
"""

import logging
import time
from packaging.version import parse as version_parse
Expand Down
13 changes: 7 additions & 6 deletions iredis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions iredis/warning.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


import sys
import click
from .commands import dangerous_commands
Expand Down
62 changes: 3 additions & 59 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tests/cli_tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/cli_tests/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions tests/cli_tests/test_pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
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,
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def judge_command_func(input_text, expect):
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:
Expand Down
13 changes: 13 additions & 0 deletions tests/unittests/test_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ def test_command_shell_options_higher_priority():
verify_ssl=None,
),
),
(
"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(
Expand Down
1 change: 1 addition & 0 deletions tests/unittests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 86fa7fe

Please sign in to comment.