Skip to content

Commit

Permalink
Fix import error for NoneType (#120)
Browse files Browse the repository at this point in the history
Fix import error for NoneType

Fix #119
  • Loading branch information
cunla committed Feb 4, 2023
1 parent 1fd562c commit 3c8252e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
19 changes: 7 additions & 12 deletions docs/about/changelog.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
## Next release

## v2.7.1
#### 🐛 Bug Fixes
- Fix import error for NoneType #527

## v2.7.0
### 🚀 Features
- Implement
- `JSON.ARRINDEX`
- `JSON.OBJLEN`
- `JSON.OBJKEYS`
- `JSON.ARRPOP`
- `JSON.ARRTRIM`
- `JSON.NUMINCRBY`
- `JSON.NUMMULTBY`
- `XADD`
- `XLEN`
- `XRANGE`
- `XREVRANGE`
- Implement `JSON.ARRINDEX`, `JSON.OBJLEN`, `JSON.OBJKEYS` ,
`JSON.ARRPOP`, `JSON.ARRTRIM`, `JSON.NUMINCRBY`, `JSON.NUMMULTBY`,
`XADD`, `XLEN`, `XRANGE`, `XREVRANGE`

### 🧰 Maintenance
- Improve json commands implementation.
Expand Down
4 changes: 2 additions & 2 deletions docs/redis-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Currently, Redis Json module is partially implemented (
see [supported commands](./redis-commands/implemented_commands.md#json-commands)).
Support for JSON commands (eg, [`JSON.GET`](https://redis.io/commands/json.get/)) is implemented using
[jsonpath-ng](https://github.com/h2non/jsonpath-ng), you can simply install it using `pip install fakeredis[json]`.
[jsonpath-ng](https://github.com/h2non/jsonpath-ng), you can simply install it using `pip install 'fakeredis[json]'`.

```pycon
>>> import fakeredis
Expand All @@ -21,4 +21,4 @@ Support for JSON commands (eg, [`JSON.GET`](https://redis.io/commands/json.get/)
## Lua support

If you wish to have Lua scripting support (this includes features like ``redis.lock.Lock``, which are implemented in
Lua), you will need [lupa](https://pypi.org/project/lupa/), you can simply install it using `pip install fakeredis[lua]`
Lua), you will need [lupa](https://pypi.org/project/lupa/), you can simply install it using `pip install 'fakeredis[lua]'`
5 changes: 4 additions & 1 deletion fakeredis/stack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from jsonpath_ng.ext import parse # noqa: F401
from redis.commands.json.path import Path # noqa: F401
from ._json_mixin import JSONCommandsMixin, JSONObject # noqa: F401
except ImportError:
except ImportError as e:
if e.name != 'jsonpath_ng':
raise e

class JSONCommandsMixin:
pass
3 changes: 1 addition & 2 deletions fakeredis/stack/_json_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from jsonpath_ng.exceptions import JsonPathParserError
from jsonpath_ng.ext import parse
from redis.commands.json.commands import JsonType
from types import NoneType
from typing import Any, Optional, Union

from fakeredis import _helpers as helpers, _msgs as msgs
Expand Down Expand Up @@ -125,7 +124,7 @@ def _json_read_iterate(method, key, *args, error_on_zero_matches=False):

class JSONCommandsMixin:
"""`CommandsMixin` for enabling RedisJSON compatibility in `fakeredis`."""

NoneType = type(None)
TYPES_EMPTY_VAL_DICT = {
dict: {},
int: 0,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "fakeredis"
packages = [
{ include = "fakeredis" },
]
version = "2.7.0"
version = "2.7.1"
description = "Fake implementation of redis API for testing purposes."
readme = "README.md"
keywords = ["redis", "rq", "django-rq", "RedisJson", ]
Expand Down

0 comments on commit 3c8252e

Please sign in to comment.