From 770359ab1b5d6d8421ee93ca9fdc7d044e0a1c78 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 11 Mar 2022 06:59:22 +0100 Subject: Merging upstream version 1.11.1. Signed-off-by: Daniel Baumann --- .bumpversion.cfg | 2 +- CHANGELOG.md | 5 + iredis/__init__.py | 2 +- iredis/client.py | 10 +- iredis/commands.py | 2 +- iredis/redis_grammar.py | 528 ++++++++++++++++++++--------------------- iredis/renders.py | 4 +- poetry.lock | 12 +- pyproject.toml | 3 +- tests/unittests/test_client.py | 13 + 10 files changed, 301 insertions(+), 280 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 18161ac..9c11de2 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.11.0 +current_version = 1.11.1 commit = True tag = True diff --git a/CHANGELOG.md b/CHANGELOG.md index 081d977..8db7aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.11.1 + +- Bugfix: Switch `distutils.version` to `packaging.version` to fix the version parse + for windows. (new dependency: pypi's python-packaging. + ## 1.11 - Dependency: Upgrade mistune lib to ^2.0. (see diff --git a/iredis/__init__.py b/iredis/__init__.py index f84c53b..c3fa782 100644 --- a/iredis/__init__.py +++ b/iredis/__init__.py @@ -1 +1 @@ -__version__ = "1.11.0" +__version__ = "1.11.1" diff --git a/iredis/client.py b/iredis/client.py index a5295fb..29045da 100644 --- a/iredis/client.py +++ b/iredis/client.py @@ -7,7 +7,7 @@ import sys import logging from subprocess import run from importlib_resources import read_text -from distutils.version import StrictVersion +from packaging.version import parse as version_parse import redis from prompt_toolkit.shortcuts import clear @@ -156,9 +156,11 @@ class Client: return connection_class(**connection_kwargs) def auth_compat(self, redis_version: str): - with_username = StrictVersion(redis_version) >= StrictVersion("6.0.0") + with_username = version_parse(redis_version) >= version_parse("6.0.0") if with_username: command2syntax["AUTH"] = "command_usernamex_password" + else: + command2syntax["AUTH"] = "command_password" def set_default_pager(self, config): configured_pager = config.pager @@ -532,7 +534,7 @@ class Client: # FIXME anything strange with single quotes? logger.debug(f"[--version--] '{server_version}'") try: - is_available = StrictVersion(server_version) > StrictVersion( + is_available = version_parse(server_version) > version_parse( available_version ) except Exception as e: @@ -670,7 +672,7 @@ class Client: # use `memory usage` to get memory, this command available from redis4.0 mem = "" - if config.version and StrictVersion(config.version) >= StrictVersion("4.0.0"): + if config.version and version_parse(config.version) >= version_parse("4.0.0"): memory_usage_value = str(self.execute("memory usage", key)) mem = f" mem: {memory_usage_value} bytes" diff --git a/iredis/commands.py b/iredis/commands.py index 9f10d53..fcbe2a4 100644 --- a/iredis/commands.py +++ b/iredis/commands.py @@ -127,7 +127,7 @@ def split_command_args(command): raise AmbiguousCommand("command is not finished") # 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()) + matcher = re.match(rf"({command_allow_multi_spaces})( |$)", command.upper()) if matcher: matched_command_len = len(matcher.group(1)) input_command = command[:matched_command_len] diff --git a/iredis/redis_grammar.py b/iredis/redis_grammar.py index 692edc6..666c0da 100644 --- a/iredis/redis_grammar.py +++ b/iredis/redis_grammar.py @@ -145,7 +145,7 @@ VALID_TOKEN = r"""( ('([^']|\\')*?') |# with single quotes ([^\s"]+) # without quotes )""" -PATTERN = fr"(?P{VALID_TOKEN})" +PATTERN = rf"(?P{VALID_TOKEN})" VALID_SLOT = r"\d+" # TODO add range? max value:16384 VALID_NODE = r"\w+" NUM = r"\d+" @@ -153,40 +153,40 @@ NNUM = r"-?\+?\(?\[?(\d+|inf)" # number cloud be negative _FLOAT = r"-?(\d|\.|e)+" LEXNUM = r"(\[\w+)|(\(\w+)|(\+)|(-)" -SLOT = fr"(?P{VALID_SLOT})" -SLOTS = fr"(?P{VALID_SLOT}(\s+{VALID_SLOT})*)" -NODE = fr"(?P{VALID_NODE})" -KEY = fr"(?P{VALID_TOKEN})" -PREFIX = fr"(?P{VALID_TOKEN})" -KEYS = fr"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" -DESTINATION = fr"(?P{VALID_TOKEN})" -NEWKEY = fr"(?P{VALID_TOKEN})" -VALUE = fr"(?P{VALID_TOKEN})" -VALUES = fr"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" -ELEMENT = fr"(?P{VALID_TOKEN})" # element for list -FIELDS = fr"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" -FIELD = fr"(?P{VALID_TOKEN})" -SFIELD = fr"(?P{VALID_TOKEN})" -SVALUE = fr"(?P{VALID_TOKEN})" -MEMBER = fr"(?P{VALID_TOKEN})" -MEMBERS = fr"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" -COUNT = fr"(?P{NNUM})" -LEN = fr"(?P{NNUM})" -RANK = fr"(?P{NNUM})" -VERSION_NUM = fr"(?P{NUM})" -MESSAGE = fr"(?P{VALID_TOKEN})" -CHANNEL = fr"(?P{VALID_TOKEN})" -GROUP = fr"(?P{VALID_TOKEN})" -CONSUMER = fr"(?P{VALID_TOKEN})" -CATEGORYNAME = fr"(?P{VALID_TOKEN})" -USERNAME = fr"(?P{VALID_TOKEN})" -RULE = fr"(?P{VALID_TOKEN})" +SLOT = rf"(?P{VALID_SLOT})" +SLOTS = rf"(?P{VALID_SLOT}(\s+{VALID_SLOT})*)" +NODE = rf"(?P{VALID_NODE})" +KEY = rf"(?P{VALID_TOKEN})" +PREFIX = rf"(?P{VALID_TOKEN})" +KEYS = rf"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +DESTINATION = rf"(?P{VALID_TOKEN})" +NEWKEY = rf"(?P{VALID_TOKEN})" +VALUE = rf"(?P{VALID_TOKEN})" +VALUES = rf"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +ELEMENT = rf"(?P{VALID_TOKEN})" # element for list +FIELDS = rf"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +FIELD = rf"(?P{VALID_TOKEN})" +SFIELD = rf"(?P{VALID_TOKEN})" +SVALUE = rf"(?P{VALID_TOKEN})" +MEMBER = rf"(?P{VALID_TOKEN})" +MEMBERS = rf"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +COUNT = rf"(?P{NNUM})" +LEN = rf"(?P{NNUM})" +RANK = rf"(?P{NNUM})" +VERSION_NUM = rf"(?P{NUM})" +MESSAGE = rf"(?P{VALID_TOKEN})" +CHANNEL = rf"(?P{VALID_TOKEN})" +GROUP = rf"(?P{VALID_TOKEN})" +CONSUMER = rf"(?P{VALID_TOKEN})" +CATEGORYNAME = rf"(?P{VALID_TOKEN})" +USERNAME = rf"(?P{VALID_TOKEN})" +RULE = rf"(?P{VALID_TOKEN})" BIT = r"(?P0|1)" -FLOAT = fr"(?P{_FLOAT})" -LONGITUDE = fr"(?P{_FLOAT})" -LATITUDE = fr"(?P{_FLOAT})" -CURSOR = fr"(?P{NUM})" -PARAMETER = fr"(?P{VALID_TOKEN})" +FLOAT = rf"(?P{_FLOAT})" +LONGITUDE = rf"(?P{_FLOAT})" +LATITUDE = rf"(?P{_FLOAT})" +CURSOR = rf"(?P{NUM})" +PARAMETER = rf"(?P{VALID_TOKEN})" DOUBLE_LUA = r'(?P[^"]*)' SINGLE_LUA = r"(?P[^']*)" INTTYPE = r"(?P(i|u)\d+)" @@ -200,21 +200,21 @@ IP = r"""(?P(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\. # https://stackoverflow.com/questions/12968093/regex-to-validate-port-number # pompt_toolkit limit: Exception: {4}-style repetition not yet supported PORT = r"(?P[1-9]|[1-5]?\d\d\d?\d?|6[1-4][0-9]\d\d\d|65[1-4]\d\d|655[1-2][0-9]|6553[1-5])" -EPOCH = fr"(?P{NUM})" -PASSWORD = fr"(?P{VALID_TOKEN})" -REPLICATIONID = fr"(?P{VALID_TOKEN})" +EPOCH = rf"(?P{NUM})" +PASSWORD = rf"(?P{VALID_TOKEN})" +REPLICATIONID = rf"(?P{VALID_TOKEN})" INDEX = r"(?P(1[0-5]|\d))" -CLIENTID = fr"(?P{NUM})" -SECOND = fr"(?P{NUM})" -TIMESTAMP = fr"(?P{NUM})" +CLIENTID = rf"(?P{NUM})" +SECOND = rf"(?P{NUM})" +TIMESTAMP = rf"(?P{NUM})" # TODO test lexer & completer for multi spaces in command # For now, redis command can have one space at most COMMAND = "(\s* (?P[\w -]+))" -MILLISECOND = fr"(?P{NUM})" -TIMESTAMPMS = fr"(?P{NUM})" +MILLISECOND = rf"(?P{NUM})" +TIMESTAMPMS = rf"(?P{NUM})" ANY = r"(?P.*)" # TODO deleted -START = fr"(?P{NNUM})" -END = fr"(?P{NNUM})" +START = rf"(?P{NNUM})" +END = rf"(?P{NNUM})" # for stream ids, special ids include: -, +, $, > and * # please see: @@ -223,111 +223,111 @@ END = fr"(?P{NNUM})" # NOTE: if miss the outer (), multi IDS won't work. STREAM_ID = "(?P[T\d:>+*\-\$]+)" -DELTA = fr"(?P{NNUM})" -OFFSET = fr"(?P{NUM})" # string offset, can't be negative +DELTA = rf"(?P{NNUM})" +OFFSET = rf"(?P{NUM})" # string offset, can't be negative SHARP_OFFSET = f"(?P\#?{NUM})" # for bitfield command -MIN = fr"(?P{NNUM})" -MAX = fr"(?P{NNUM})" -POSITION = fr"(?P{NNUM})" -TIMEOUT = fr"(?P{NUM})" -SCORE = fr"(?P{_FLOAT})" -LEXMIN = fr"(?P{LEXNUM})" -LEXMAX = fr"(?P{LEXNUM})" -WEIGHTS = fr"(?P{_FLOAT}(\s+{_FLOAT})*)" -IP_PORT = fr"(?P{IP}:{PORT})" -HOST = fr"(?P{VALID_TOKEN})" +MIN = rf"(?P{NNUM})" +MAX = rf"(?P{NNUM})" +POSITION = rf"(?P{NNUM})" +TIMEOUT = rf"(?P{NUM})" +SCORE = rf"(?P{_FLOAT})" +LEXMIN = rf"(?P{LEXNUM})" +LEXMAX = rf"(?P{LEXNUM})" +WEIGHTS = rf"(?P{_FLOAT}(\s+{_FLOAT})*)" +IP_PORT = rf"(?P{IP}:{PORT})" +HOST = rf"(?P{VALID_TOKEN})" # const choices -FAILOVERCHOICE = fr"(?P{c('failoverchoice')})" -WITHSCORES = fr"(?P{c('withscores')})" -LIMIT = fr"(?P{c('limit')})" -EXPIRATION = fr"(?P{c('expiration')})" -CONDITION = fr"(?P{c('condition')})" -OPERATION = fr"(?P{c('operation')})" -CHANGED = fr"(?P{c('changed')})" -INCR = fr"(?P{c('incr')})" -RESETCHOICE = fr"(?P{c('resetchoice')})" -MATCH = fr"(?P{c('match')})" -COUNT_CONST = fr"(?P{c('count_const')})" -TYPE_CONST = fr"(?P{c('type_const')})" -TYPE = fr"(?P{c('type')})" -POSITION_CHOICE = fr"(?P{c('position_choice')})" -ERROR = fr"(?P{c('error')})" -ASYNC = fr"(?P{c('async')})" -CONNTYPE = fr"(?P{c('conntype')})" -SAMPLES = fr"(?P{c('samples')})" -SLOTSUBCMD = fr"(?P{c('slotsubcmd')})" -WEIGHTS_CONST = fr"(?P{c('weights_const')})" -AGGREGATE_CONST = fr"(?P{c('aggregate_const')})" -AGGREGATE = fr"(?P{c('aggregate')})" -SLOWLOGSUB = fr"(?P{c('slowlogsub')})" -SHUTDOWN = fr"(?P{c('shutdown')})" -SWITCH = fr"(?P{c('switch')})" -ON_OFF = fr"(?P{c('on_off')})" -CONST_ID = fr"(?P{c('const_id')})" -CONST_USER = fr"(?P{c('const_user')})" -ADDR = fr"(?P{c('addr')})" -SKIPME = fr"(?P{c('skipme')})" -YES = fr"(?P{c('yes')})" -MIGRATECHOICE = fr"(?P{c('migratechoice')})" -AUTH = fr"(?P{c('auth')})" -CONST_KEYS = fr"(?P{c('const_keys')})" -OBJECT = fr"(?P{c('object')})" -SUBRESTORE = fr"(?P{c('subrestore')})" -DISTUNIT = fr"(?P{c('distunit')})" -GEOCHOICE = fr"(?P{c('geochoice')})" -ORDER = fr"(?P{c('order')})" -CONST_STORE = fr"(?P{c('const_store')})" -CONST_STOREDIST = fr"(?P{c('const_storedist')})" -PUBSUBCMD = fr"(?P{c('pubsubcmd')})" -SCRIPTDEBUG = fr"(?P{c('scriptdebug')})" -HELP = fr"(?P{c('help')})" -STREAM = fr"(?P{c('stream')})" -STREAM_GROUPS = fr"(?P{c('stream_groups')})" -STREAM_GROUP = fr"(?P{c('stream_group')})" -STREAM_CONSUMERS = fr"(?P{c('stream_consumers')})" -STREAM_CREATE = fr"(?P{c('stream_create')})" -STREAM_SETID = fr"(?P{c('stream_setid')})" -STREAM_DESTROY = fr"(?P{c('stream_destroy')})" -STREAM_DELCONSUMER = fr"(?P{c('stream_delconsumer')})" -MAXLEN = fr"(?P{c('maxlen')})" +FAILOVERCHOICE = rf"(?P{c('failoverchoice')})" +WITHSCORES = rf"(?P{c('withscores')})" +LIMIT = rf"(?P{c('limit')})" +EXPIRATION = rf"(?P{c('expiration')})" +CONDITION = rf"(?P{c('condition')})" +OPERATION = rf"(?P{c('operation')})" +CHANGED = rf"(?P{c('changed')})" +INCR = rf"(?P{c('incr')})" +RESETCHOICE = rf"(?P{c('resetchoice')})" +MATCH = rf"(?P{c('match')})" +COUNT_CONST = rf"(?P{c('count_const')})" +TYPE_CONST = rf"(?P{c('type_const')})" +TYPE = rf"(?P{c('type')})" +POSITION_CHOICE = rf"(?P{c('position_choice')})" +ERROR = rf"(?P{c('error')})" +ASYNC = rf"(?P{c('async')})" +CONNTYPE = rf"(?P{c('conntype')})" +SAMPLES = rf"(?P{c('samples')})" +SLOTSUBCMD = rf"(?P{c('slotsubcmd')})" +WEIGHTS_CONST = rf"(?P{c('weights_const')})" +AGGREGATE_CONST = rf"(?P{c('aggregate_const')})" +AGGREGATE = rf"(?P{c('aggregate')})" +SLOWLOGSUB = rf"(?P{c('slowlogsub')})" +SHUTDOWN = rf"(?P{c('shutdown')})" +SWITCH = rf"(?P{c('switch')})" +ON_OFF = rf"(?P{c('on_off')})" +CONST_ID = rf"(?P{c('const_id')})" +CONST_USER = rf"(?P{c('const_user')})" +ADDR = rf"(?P{c('addr')})" +SKIPME = rf"(?P{c('skipme')})" +YES = rf"(?P{c('yes')})" +MIGRATECHOICE = rf"(?P{c('migratechoice')})" +AUTH = rf"(?P{c('auth')})" +CONST_KEYS = rf"(?P{c('const_keys')})" +OBJECT = rf"(?P{c('object')})" +SUBRESTORE = rf"(?P{c('subrestore')})" +DISTUNIT = rf"(?P{c('distunit')})" +GEOCHOICE = rf"(?P{c('geochoice')})" +ORDER = rf"(?P{c('order')})" +CONST_STORE = rf"(?P{c('const_store')})" +CONST_STOREDIST = rf"(?P{c('const_storedist')})" +PUBSUBCMD = rf"(?P{c('pubsubcmd')})" +SCRIPTDEBUG = rf"(?P{c('scriptdebug')})" +HELP = rf"(?P{c('help')})" +STREAM = rf"(?P{c('stream')})" +STREAM_GROUPS = rf"(?P{c('stream_groups')})" +STREAM_GROUP = rf"(?P{c('stream_group')})" +STREAM_CONSUMERS = rf"(?P{c('stream_consumers')})" +STREAM_CREATE = rf"(?P{c('stream_create')})" +STREAM_SETID = rf"(?P{c('stream_setid')})" +STREAM_DESTROY = rf"(?P{c('stream_destroy')})" +STREAM_DELCONSUMER = rf"(?P{c('stream_delconsumer')})" +MAXLEN = rf"(?P{c('maxlen')})" APPROXIMATELY = r"(?P~)" -IDEL = fr"(?P{c('idel')})" -TIME = fr"(?P