Skip to content

Commit da0b3fa

Browse files
Merge pull request #1 from redis/master
Merge master
2 parents 5604573 + 9235a72 commit da0b3fa

22 files changed

+249
-292
lines changed

.github/release-drafter-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ autolabeler:
1515
branch:
1616
- '/feature-.+'
1717
categories:
18-
- title: 'Breaking Changes'
18+
- title: '🔥 Breaking Changes'
1919
labels:
2020
- 'breakingchange'
2121
- title: '🚀 New Features'

.readthedocs.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
python:
4+
install:
5+
- requirements: ./docs/requirements.txt
6+
7+
build:
8+
os: ubuntu-20.04
9+
tools:
10+
python: "3.9"
11+
12+
sphinx:
13+
configuration: docs/conf.py

docs/conf.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@
4646

4747
# General information about the project.
4848
project = "redis-py"
49-
copyright = "2016, Andy McCurdy"
49+
copyright = "2021, Redis Inc."
5050

5151
# The version info for the project you're documenting, acts as replacement for
5252
# |version| and |release|, also used in various other places throughout the
5353
# built documents.
5454
#
5555
# The short X.Y version.
56-
version = "2.10.5"
56+
version = "4.0.9"
5757
# The full version, including alpha/beta/rc tags.
58-
release = "2.10.5"
58+
release = "4.0.0"
5959

6060
# The language for content autogenerated by Sphinx. Refer to documentation
6161
# for a list of supported languages.
@@ -191,7 +191,7 @@
191191
("index",
192192
"redis-py.tex",
193193
"redis-py Documentation",
194-
"Andy McCurdy",
194+
"Redis Inc",
195195
"manual"),
196196
]
197197

@@ -240,7 +240,7 @@
240240
"index",
241241
"redis-py",
242242
"redis-py Documentation",
243-
"Andy McCurdy",
243+
"Redis Inc",
244244
"redis-py",
245245
"One line description of project.",
246246
"Miscellaneous",
@@ -257,6 +257,6 @@
257257
# texinfo_show_urls = 'footnote'
258258

259259
epub_title = "redis-py"
260-
epub_author = "Andy McCurdy"
261-
epub_publisher = "Andy McCurdy"
262-
epub_copyright = "2011, Andy McCurdy"
260+
epub_author = "Redis Inc"
261+
epub_publisher = "Redis Inc"
262+
epub_copyright = "2021, Redis Inc"

docs/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,21 @@ Contents:
2222
.. automodule:: redis
2323
:members:
2424

25+
.. automodule:: redis.backoff
26+
:members:
27+
28+
.. automodule:: redis.connection
29+
:members:
30+
31+
.. automodule:: redis.commands
32+
:members:
33+
34+
.. automodule:: redis.exceptions
35+
:members:
36+
37+
.. automodule:: redis.lock
38+
:members:
39+
2540
.. automodule:: redis.sentinel
2641
:members:
42+

docs/make.bat

Lines changed: 0 additions & 190 deletions
This file was deleted.

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sphinx<2
2+
docutils<0.18

redis/client.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ class Redis(RedisModuleCommands, CoreCommands, object):
703703
'CLUSTER SET-CONFIG-EPOCH': bool_ok,
704704
'CLUSTER SETSLOT': bool_ok,
705705
'CLUSTER SLAVES': parse_cluster_nodes,
706-
'COMMAND': int,
707706
'COMMAND COUNT': int,
708707
'CONFIG GET': parse_config_get,
709708
'CONFIG RESETSTAT': bool_ok,
@@ -891,19 +890,25 @@ def __init__(self, host='localhost', port=6379,
891890
self.response_callbacks = CaseInsensitiveDict(
892891
self.__class__.RESPONSE_CALLBACKS)
893892

893+
# preload our class with the available redis commands
894+
try:
895+
self.__redis_commands__()
896+
except RedisError:
897+
pass
898+
894899
def __repr__(self):
895900
return "%s<%s>" % (type(self).__name__, repr(self.connection_pool))
896901

897902
def set_response_callback(self, command, callback):
898903
"Set a custom Response Callback"
899904
self.response_callbacks[command] = callback
900905

901-
def load_external_module(self, modname, funcname, func):
906+
def load_external_module(self, funcname, func,
907+
):
902908
"""
903909
This function can be used to add externally defined redis modules,
904910
and their namespaces to the redis client.
905-
modname - A string containing the name of the redis module to look for
906-
in the redis info block.
911+
907912
funcname - A string containing the name of the function to create
908913
func - The function, being added to this class.
909914
@@ -914,31 +919,25 @@ def load_external_module(self, modname, funcname, func):
914919
from redis import Redis
915920
from foomodule import F
916921
r = Redis()
917-
r.load_external_module("foomod", "foo", F)
922+
r.load_external_module("foo", F)
918923
r.foo().dothing('your', 'arguments')
919924
920925
For a concrete example see the reimport of the redisjson module in
921926
tests/test_connection.py::test_loading_external_modules
922927
"""
923-
mods = self.loaded_modules
924-
if modname.lower() not in mods:
925-
raise ModuleError("{} is not loaded in redis.".format(modname))
926928
setattr(self, funcname, func)
927929

928-
@property
929-
def loaded_modules(self):
930-
key = '__redis_modules__'
931-
mods = getattr(self, key, None)
932-
if mods is not None:
933-
return mods
934-
930+
def __redis_commands__(self):
931+
"""Store the list of available commands, for our redis instance."""
932+
cmds = getattr(self, '__commands__', None)
933+
if cmds is not None:
934+
return cmds
935935
try:
936-
mods = {f.get('name').lower(): f.get('ver')
937-
for f in self.info().get('modules')}
938-
except TypeError:
939-
mods = []
940-
setattr(self, key, mods)
941-
return mods
936+
cmds = [c[0].upper().decode() for c in self.command()]
937+
except AttributeError: # if encoded
938+
cmds = [c[0].upper() for c in self.command()]
939+
self.__commands__ = cmds
940+
return cmds
942941

943942
def pipeline(self, transaction=True, shard_hint=None):
944943
"""

redis/commands/core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,10 +2520,13 @@ def zrange(self, name, start, end, desc=False, withscores=False,
25202520
``offset`` and ``num`` are specified, then return a slice of the range.
25212521
Can't be provided when using ``bylex``.
25222522
"""
2523-
# Supports old implementation: need to support ``desc`` also for version < 6.2.0
2524-
if not byscore and not bylex and (offset is None and num is None) and desc:
2523+
# Need to support ``desc`` also when using old redis version
2524+
# because it was supported in 3.5.3 (of redis-py)
2525+
if not byscore and not bylex and (offset is None and num is None) \
2526+
and desc:
25252527
return self.zrevrange(name, start, end, withscores,
25262528
score_cast_func)
2529+
25272530
return self._zrange('ZRANGE', None, name, start, end, desc, byscore,
25282531
bylex, withscores, score_cast_func, offset, num)
25292532

@@ -3312,6 +3315,9 @@ def command_info(self):
33123315
def command_count(self):
33133316
return self.execute_command('COMMAND COUNT')
33143317

3318+
def command(self):
3319+
return self.execute_command('COMMAND')
3320+
33153321

33163322
class Script:
33173323
"An executable Lua script object returned by ``register_script``"

0 commit comments

Comments
 (0)