Without this patch, mypy complains that an object of type FakeRedisMixin cannot be assigned to a variable of type FakeRedis | RedisCluster, even though the class we called it on is of type FakeRedis and the returned object will also be a FakeRedis.
client code which explicitly types for FakeRedisMixin should be unaffected.
Tested locally and passes fine with poetry run mypy fakeredis/_server.py on both python 3.7 and 3.11. (a full mypy run isn't currently clean, so i limited my test just to this file).
Additionally, also fixed…
_server.py:142: error: Incompatible default for argument "lua_modules" (default has type "None", argument has type "Set[str]") [assignment]
_server.py:142: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
_server.py:142: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
… in this file. That change seems to be needed in other files too, but I figured that was out of scope.
This fixes issues when you have strongly typed client code using that method.
An example would be something like
Without this patch, mypy complains that an object of type
FakeRedisMixin
cannot be assigned to a variable of typeFakeRedis | RedisCluster
, even though the class we called it on is of typeFakeRedis
and the returned object will also be aFakeRedis
.client code which explicitly types for
FakeRedisMixin
should be unaffected.Tested locally and passes fine with
poetry run mypy fakeredis/_server.py
on both python 3.7 and 3.11. (a full mypy run isn't currently clean, so i limited my test just to this file).Additionally, also fixed…
… in this file. That change seems to be needed in other files too, but I figured that was out of scope.