-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make FakeStrictRedis inherit redis.StrictRedis #36
Conversation
As per the contribution guidelines this will need tests before I can merge this. This should be a pretty easy test to write so I'll go ahead and work on this. |
Hmm, actually, in writing tests for this I'm not sure of the desired behavior. Can you elaborate on your use case? How would someone be using the isinstance checks here? Does this also mean that |
I was using FakeRedis with rq, which insisted the Queue should be passed a real Redis instance. Now I think it is quite trivial to workaround this, by making a class that inherits from both FakeRedis and Redis. So I think this can be closed? |
I added a commit that makes FakeRedis inherit Redis. |
Some libraries check whether the type of an argument is redis.StrictRedis or not. If FakeStrictRedis is complete, this inheritance should make no difference. It also makes FakeRedis inherit redis.Redis
rebased to the current master |
This would also allow for directly using some of the convenience functions in StrictRedis. Right now in #73 I have to copy over the iterator code because I cannot do something like:
|
On second though this seems like it might not be a great idea because you then have to add NotImplementedError on all of the not supported library functions. |
After thinking about it more, I tend to agree with @btashton. Subclassing would mean we may inadvertently call into the real redis-py module, which is not ideal. Given it's easy to make your own custom subclass that inherits from both classes, I'd prefer not to have this in fakeredis. Closing for now. |
Some libraries check whether the type of an argument is
redis.StrictRedis or not. If FakeStrictRedis is complete, this
inheritance should make no difference.