-
Notifications
You must be signed in to change notification settings - Fork 14
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
update the return type of scan family #135
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #135 +/- ##
=======================================
Coverage 76.19% 76.19%
=======================================
Files 130 130
Lines 33907 33907
=======================================
Hits 25837 25837
Misses 8070 8070 ☔ View full report in Codecov by Sentry. |
Hey @amirreza8002 ! Thanks a lot for your contribution! Do I understand correctly that the return type was wrong because this part of code is not in fact async? :) Or is it something else I'm missing? |
hi also, to my knowledge, none of the methods in valkey-py, sync or async, return an awaitable also |
Could you expand this thought please?
Yeah, it seems like Anyway, this piece of PEP 484 says we should not mark the return type as
async def spam(ignored: int) -> str:
return 'spam'
async def foo() -> None:
bar = await spam(42) # type: str
What I'm reading from this document and PEP 585, it's only plain Also, I'm a bit concerned that Sorry for being picky here, I'm just not that experienced with type hints in Python so wanna make sure we're not breaking anything here :) |
hi meaning the first element of the tuple is an integer (named cursor), and the second element is either a list or a dict depending on the method to test this i simply put some sample data in the database, queried it with these methods, and printed the type if the values returned. the Awaitable type hint, from what i understand and my IDE tells me, is for when the value it self is in fact awaitable, meaning it returns a callable I'm not a type hint guy myself so be as picky as you can :) if needed I'll post some sample codes here tomorrow to demonstrate |
on another note let me know if that's the case |
Could you please tell me what type hints improvements did you have in mind particularly? |
imports like we can just use not that important but avoids some importing |
another thought since it'll take time to fix the types of this package, is it possible to create a new branch at valkey-py and move this work and other people's work related to types there? |
I'm actually thinking that perhaps the best idea would be to start applying your changes with smaller chunks. A single PR (a single commit, even!) affecting 17 thousands lines of code sounds scary and will take significant time to review and test. Do you think that would be feasible? And what's your opinion on that? |
some basic exapmels for this PR: scan:
sscan:
hscan:
zscan:
|
mm |
Maybe add it file-by-file? Or in larger files like |
It is fine to fix small chunks of typing issues one by one over time or work on a huge draft PR that fix everything at once everything is fixed (e.g. you have mypy enabled and it's all green) it can be split in smaller PRs for easier review. |
Yeah, thanks! This PR looks good and I'll merge it now. I'd like to continue the discussion regarding the types tho. We can continue it here or do it in Matrix: https://matrix.to/#/#valkey:matrix.org |
Signed-off-by: amirreza <[email protected]>
i'll probably go method by method, or a few methods per PR
i don't have matrix at the moment, i'll see if i can set it up |
hi
just did a few methods to see how it goes
i plan to continue the work, so if you have a feedback i'm happy to hear.
one thing i notice is that a lot of valkey method's return types include
Awaitable
, which is plain wrong and very annoying, so hoepfully you'll see more of me on this :)