fix: FakeRedisMixin.from_url() return type is really Self. #305
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.