From 668977aa6a04dbdfb1c4856dbf8577800505873e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 25 Jan 2022 21:03:28 +0100 Subject: Merging upstream version 1.11.0: - compatible with mistune 2.0 (Closes: #1003572). Signed-off-by: Daniel Baumann --- .bumpversion.cfg | 2 +- .github/workflows/test.yaml | 4 + CHANGELOG.md | 5 ++ iredis/__init__.py | 2 +- iredis/client.py | 26 +++---- iredis/commands.py | 6 +- iredis/completers.py | 8 +- iredis/data/commands.json | 6 +- iredis/data/commands/eval.md | 2 +- iredis/data/commands/xadd.md | 2 +- iredis/data/iredisrc | 6 +- iredis/entry.py | 2 +- iredis/markdown.py | 37 +++++---- iredis/redis_grammar.py | 2 +- iredis/renders.py | 8 +- iredis/style.py | 4 +- iredis/utils.py | 2 +- poetry.lock | 108 ++++++++++++++------------- pyproject.toml | 4 +- tests/unittests/command_parse/test_stream.py | 2 +- tests/unittests/test_client.py | 4 +- 21 files changed, 126 insertions(+), 116 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index ad03b3a..18161ac 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.10.0 +current_version = 1.11.0 commit = True tag = True diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7c992c7..88e3ee4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -56,6 +56,10 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: codespell-project/actions-codespell@master + with: + ignore_words_list: fo,ists,oll,optin,ot,smove,tre,whe + exclude_file: docs/assets/demo.svg - uses: actions/setup-python@v1 with: python-version: 3.7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 84687be..081d977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.11 + +- Dependency: Upgrade mistune lib to ^2.0. (see + https://github.com/laixintao/iredis/issues/232) + ## 1.10 - Feature: more human readable output for `HELP` command like `ACL HELP` and diff --git a/iredis/__init__.py b/iredis/__init__.py index fcfdf38..f84c53b 100644 --- a/iredis/__init__.py +++ b/iredis/__init__.py @@ -1 +1 @@ -__version__ = "1.10.0" +__version__ = "1.11.0" diff --git a/iredis/client.py b/iredis/client.py index 2c9bda5..a5295fb 100644 --- a/iredis/client.py +++ b/iredis/client.py @@ -224,7 +224,7 @@ class Client: logger.info( f"execute by connection: connection={connection}, name={command_name}, {args}, {options}" ) - retry_times = config.retry_times # FIXME configureable + retry_times = config.retry_times # FIXME configurable last_error = None need_refresh_connection = False @@ -487,7 +487,7 @@ class Client: """ if command_name.upper() == "HELLO": raise NotSupport("IRedis currently not support RESP3, sorry about that.") - # TRANSATION state chage + # TRANSACTION state change if command_name.upper() in ["EXEC", "DISCARD"]: logger.debug(f"[After hook] Command is {command_name}, unset transaction.") config.transaction = False @@ -527,25 +527,25 @@ class Client: rendered_detail = markdown.render(doc) summary_dict = commands_summary[command_summary_name] - avaiable_version = summary_dict.get("since", "?") + available_version = summary_dict.get("since", "?") server_version = config.version # FIXME anything strange with single quotes? logger.debug(f"[--version--] '{server_version}'") try: - is_avaiable = StrictVersion(server_version) > StrictVersion( - avaiable_version + is_available = StrictVersion(server_version) > StrictVersion( + available_version ) except Exception as e: logger.exception(e) - is_avaiable = None + is_available = None - if is_avaiable: - avaiable_text = f"(Avaiable on your redis-server: {server_version})" - elif is_avaiable is False: - avaiable_text = f"(Not avaiable on your redis-server: {server_version})" + if is_available: + available_text = f"(Available on your redis-server: {server_version})" + elif is_available is False: + available_text = f"(Not available on your redis-server: {server_version})" else: - avaiable_text = "" - since_text = f"{avaiable_version} {avaiable_text}" + available_text = "" + since_text = f"{available_version} {available_text}" summary = [ ("", "\n"), @@ -658,7 +658,7 @@ class Client: yield FormattedText([("class:dockey", "XINFO: ")]) yield renders.OutputRender.render_list(xinfo) - # incase the result is too long, we yield only once so the outputer + # in case the result is too long, we yield only once so the outputer # can pager it. peek_response = [] key_type = nativestr(self.execute("type", key)) diff --git a/iredis/commands.py b/iredis/commands.py index dcd457f..9f10d53 100644 --- a/iredis/commands.py +++ b/iredis/commands.py @@ -20,7 +20,7 @@ def _load_command_summary(): def _load_command(): """ - load command informations from file. + load command information from file. :returns: - original_commans: dict, command name : Command - command_group: dict, group_name: command_names @@ -115,7 +115,7 @@ def split_command_args(command): command = command.strip() for command_name in all_commands: - # for command that is paritaly inputed, like `command in`, we should + # for command that is paritaly 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() @@ -125,7 +125,7 @@ def split_command_args(command): and command_name != normalized_input_command ): raise AmbiguousCommand("command is not finished") - # allow multiplt space in user inputed command + # allow multiple space in user input command command_allow_multi_spaces = "[ ]+".join(command_name.split()) matcher = re.match(fr"({command_allow_multi_spaces})( |$)", command.upper()) if matcher: diff --git a/iredis/completers.py b/iredis/completers.py index afdc7ef..f5d922e 100644 --- a/iredis/completers.py +++ b/iredis/completers.py @@ -94,8 +94,8 @@ class TimestampCompleter(Completer): return current = int(text) now = pendulum.now() - for unit, minium in self.when_lower_than.items(): - if current <= minium: + for unit, minimum in self.when_lower_than.items(): + if current <= minimum: dt = now.subtract(**{f"{unit}s": current}) meta = f"{text} {unit}{'s' if current > 1 else ''} ago ({dt.format('YYYY-MM-DD HH:mm:ss')})" yield Completion( @@ -205,7 +205,7 @@ class IRedisCompleter(Completer): for _token_in_command in tokens_in_command: # prompt_toolkit didn't support multi tokens # like DEL key1 key2 key3 - # so we have to split them manualy + # so we have to split them manually for single_token in strip_quote_args(_token_in_command): _completer.touch(single_token) @@ -310,7 +310,7 @@ class IRedisCompleter(Completer): "member": member_completer, "members": member_completer, # zmember - # TODO sperate sorted set and set + # TODO separate sorted set and set # hash fields "field": field_completer, "fields": field_completer, diff --git a/iredis/data/commands.json b/iredis/data/commands.json index 1b0ae22..74093cc 100644 --- a/iredis/data/commands.json +++ b/iredis/data/commands.json @@ -2310,7 +2310,7 @@ "WITHVALUES" ], "optional": true - } + } ], "optional": true } @@ -4378,7 +4378,7 @@ "WITHSCORES" ], "optional": true - } + } ], "optional": true } @@ -5048,7 +5048,7 @@ }, "XADD": { "summary": "Appends a new entry to a stream", - "complexity": "O(1) when adding a new entry, O(N) when trimming where N being the number of entires evicted.", + "complexity": "O(1) when adding a new entry, O(N) when trimming where N being the number of entries evicted.", "arguments": [ { "name": "key", diff --git a/iredis/data/commands/eval.md b/iredis/data/commands/eval.md index 3618ac6..f85d727 100644 --- a/iredis/data/commands/eval.md +++ b/iredis/data/commands/eval.md @@ -733,7 +733,7 @@ Valid formats: > - big endian < - little endian ![num] - alignment -x - pading +x - padding b/B - signed/unsigned byte h/H - signed/unsigned short l/L - signed/unsigned long diff --git a/iredis/data/commands/xadd.md b/iredis/data/commands/xadd.md index aca1de7..8a80556 100644 --- a/iredis/data/commands/xadd.md +++ b/iredis/data/commands/xadd.md @@ -52,7 +52,7 @@ to match the one of this other system. documentation page for more information. This allows adding new entries and keeping the stream's size in check with a single call to `XADD`, effectively capping the stream with an arbitrary threshold. Although exact trimming is -possible and is the default, due to the internal representation of steams it is +possible and is the default, due to the internal representation of streams it is more efficient to add an entry and trim stream with `XADD` using **almost exact** trimming (the `~` argument). diff --git a/iredis/data/iredisrc b/iredis/data/iredisrc index 5baef86..bf79e90 100644 --- a/iredis/data/iredisrc +++ b/iredis/data/iredisrc @@ -30,9 +30,9 @@ socket_keepalive = True shell = True # decode redis response, default None -decode = +decode = -# enable pager? defualt to True, you can disable it by changing it to False +# enable pager? default to True, you can disable it by changing it to False enable_pager = True # pager setting when line is too tall @@ -52,7 +52,7 @@ bottom_bar = True warning = True # IRedis log for debugging, leave this blank will disable log. -# You don't need this unless you are debuging iredis. +# You don't need this unless you are debugging iredis. # Be careful this will log your commands input (include AUTH with password) to # log file. # eg. ~/.iredis.log diff --git a/iredis/entry.py b/iredis/entry.py index eb57668..2a9dc05 100644 --- a/iredis/entry.py +++ b/iredis/entry.py @@ -160,7 +160,7 @@ class Rainbow: def prompt_message(client): - # TODO custome prompt + # TODO custom prompt text = "{hostname}> ".format(hostname=str(client)) if config.rainbow: return list(zip(Rainbow(), text)) diff --git a/iredis/markdown.py b/iredis/markdown.py index ff2b726..6f26642 100644 --- a/iredis/markdown.py +++ b/iredis/markdown.py @@ -13,24 +13,24 @@ from prompt_toolkit.formatted_text import to_formatted_text, HTML logger = logging.getLogger(__name__) -class TerminalRender(mistune.Renderer): +class TerminalRender(mistune.HTMLRenderer): def _to_title(self, text): return f"{text}\n{'='*len(text)}\n" def paragraph(self, text): return text + "\n\n" - def block_code(self, code, language=None): + def block_code(self, code, info=None): code = "\n".join([" " + line for line in code.splitlines()]) return super().block_code(code) - def header(self, text, level, raw=None): + def heading(self, text, level): if level == 2: header_text = self._to_title(text) - return super().header(header_text, 2) - return super().header(self._to_title(text), level) + return super().heading(header_text, 2) + return super().heading(self._to_title(text), level) - def list(self, body, ordered=True): + def list(self, body, ordered, level, start=None): """Rendering list tags like ``