diff options
Diffstat (limited to 'redis/commands/json')
-rw-r--r-- | redis/commands/json/__init__.py | 10 | ||||
-rw-r--r-- | redis/commands/json/commands.py | 38 | ||||
-rw-r--r-- | redis/commands/json/decoders.py | 7 |
3 files changed, 27 insertions, 28 deletions
diff --git a/redis/commands/json/__init__.py b/redis/commands/json/__init__.py index d634dbd..12c0648 100644 --- a/redis/commands/json/__init__.py +++ b/redis/commands/json/__init__.py @@ -1,12 +1,10 @@ -from json import JSONDecoder, JSONEncoder, JSONDecodeError +from json import JSONDecodeError, JSONDecoder, JSONEncoder + +import redis -from .decoders import ( - decode_list, - bulk_of_jsons, -) from ..helpers import nativestr from .commands import JSONCommands -import redis +from .decoders import bulk_of_jsons, decode_list class JSON(JSONCommands): diff --git a/redis/commands/json/commands.py b/redis/commands/json/commands.py index 1affaaf..e7f07b6 100644 --- a/redis/commands/json/commands.py +++ b/redis/commands/json/commands.py @@ -1,8 +1,10 @@ -from .path import Path -from .decoders import decode_dict_keys from deprecated import deprecated + from redis.exceptions import DataError +from .decoders import decode_dict_keys +from .path import Path + class JSONCommands: """json commands.""" @@ -29,8 +31,7 @@ class JSONCommands: For more information: https://oss.redis.com/redisjson/commands/#jsonarrindex """ # noqa return self.execute_command( - "JSON.ARRINDEX", name, str(path), self._encode(scalar), - start, stop + "JSON.ARRINDEX", name, str(path), self._encode(scalar), start, stop ) def arrinsert(self, name, path, index, *args): @@ -66,8 +67,7 @@ class JSONCommands: For more information: https://oss.redis.com/redisjson/commands/#jsonarrtrim """ # noqa - return self.execute_command("JSON.ARRTRIM", name, str(path), - start, stop) + return self.execute_command("JSON.ARRTRIM", name, str(path), start, stop) def type(self, name, path=Path.rootPath()): """Get the type of the JSON value under ``path`` from key ``name``. @@ -109,7 +109,7 @@ class JSONCommands: "JSON.NUMINCRBY", name, str(path), self._encode(number) ) - @deprecated(version='4.0.0', reason='deprecated since redisjson 1.0.0') + @deprecated(version="4.0.0", reason="deprecated since redisjson 1.0.0") def nummultby(self, name, path, number): """Multiply the numeric (integer or floating point) JSON value under ``path`` at key ``name`` with the provided ``number``. @@ -218,7 +218,7 @@ class JSONCommands: ``name``. For more information: https://oss.redis.com/redisjson/commands/#jsonstrlen - """ # noqa + """ # noqa pieces = [name] if path is not None: pieces.append(str(path)) @@ -240,9 +240,7 @@ class JSONCommands: For more information: https://oss.redis.com/redisjson/commands/#jsonstrappend """ # noqa pieces = [name, str(path), self._encode(value)] - return self.execute_command( - "JSON.STRAPPEND", *pieces - ) + return self.execute_command("JSON.STRAPPEND", *pieces) def debug(self, subcommand, key=None, path=Path.rootPath()): """Return the memory usage in bytes of a value under ``path`` from @@ -252,8 +250,7 @@ class JSONCommands: """ # noqa valid_subcommands = ["MEMORY", "HELP"] if subcommand not in valid_subcommands: - raise DataError("The only valid subcommands are ", - str(valid_subcommands)) + raise DataError("The only valid subcommands are ", str(valid_subcommands)) pieces = [subcommand] if subcommand == "MEMORY": if key is None: @@ -262,17 +259,20 @@ class JSONCommands: pieces.append(str(path)) return self.execute_command("JSON.DEBUG", *pieces) - @deprecated(version='4.0.0', - reason='redisjson-py supported this, call get directly.') + @deprecated( + version="4.0.0", reason="redisjson-py supported this, call get directly." + ) def jsonget(self, *args, **kwargs): return self.get(*args, **kwargs) - @deprecated(version='4.0.0', - reason='redisjson-py supported this, call get directly.') + @deprecated( + version="4.0.0", reason="redisjson-py supported this, call get directly." + ) def jsonmget(self, *args, **kwargs): return self.mget(*args, **kwargs) - @deprecated(version='4.0.0', - reason='redisjson-py supported this, call get directly.') + @deprecated( + version="4.0.0", reason="redisjson-py supported this, call get directly." + ) def jsonset(self, *args, **kwargs): return self.set(*args, **kwargs) diff --git a/redis/commands/json/decoders.py b/redis/commands/json/decoders.py index b19395c..b938471 100644 --- a/redis/commands/json/decoders.py +++ b/redis/commands/json/decoders.py @@ -1,6 +1,7 @@ -from ..helpers import nativestr -import re import copy +import re + +from ..helpers import nativestr def bulk_of_jsons(d): @@ -33,7 +34,7 @@ def unstring(obj): One can't simply call int/float in a try/catch because there is a semantic difference between (for example) 15.0 and 15. """ - floatreg = '^\\d+.\\d+$' + floatreg = "^\\d+.\\d+$" match = re.findall(floatreg, obj) if match != []: return float(match[0]) |