-
Notifications
You must be signed in to change notification settings - Fork 9
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
Types #93
base: main
Are you sure you want to change the base?
Types #93
Conversation
Woops, I wanted to do a PR on my own repo, but mixed it up and did the PR here, sorry for that. It is not ready for merging, but I guess as it is here now, feel free to comment. (WIP for #84) |
Sure. As I mentioned in the issue, I'd really like to see the types within the code and not in separate files. Also please you |
I'll also squash the commits, it is a mess for no good reason right now. |
Now a note that is possibly a bit of a problem: That's the reason the tests are failing there : https://github.com/Rafiot/valkey-py/actions/runs/10808666835/job/29982264205?pr=1#step:6:300 But also, the test suite is very much not helping as it casts the list to a set when len > 1 (again, see test suite above). Question: Should we cast the response of smembers to a set? Or change the type hints? |
We should change the type hints. There is some difference between RESP3 sets and Python's sets and it is not possible to represents all RESP3 sets as sets in Python, so the functions has to return a list. Its up to the user to cast it to set when/if they know that is is safe to do so. Previous versions of the code returned a set, this is probably why the type hints are wrong. |
smsmbers is now marked as returning a list |
Signed-off-by: Raphaël Vinot <[email protected]>
@Rafiot I noticed the last commit changes some test code as well. That's a bit odd. Is your branch based on some old commit in In my understanding, this PR should not change any behaviour of the library, it only adds the type hints. |
@mkmkme I'm using the test suite as a way to validate the type hints, so to do that, I need to add type hints to the test suite, which explains the changes. I'll review it, but it should not change the logic of the tests just add the hints in a way mypy is happy. It seemed to me to be the best way to make sure the type hints are in-line with the current codebase. |
Oh, true. So I'm confused how the tests as they are now can pass, because the response is definitely a list, not a set:
|
I just want to quickly update you on that one: I haven't forgotten, and will get back to it asap. This month got busy but I should be able to get back to this PR in a few days. |
Pull Request check-list
Description of change