-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Type hints #7
Comments
Hi @Tinche - I'd strongly recommend holding off on spending any time on adding type hints (or any non bug fix changes) on the state of the code that is in master branch right now (which is approximately == 2.x branch). The I'm currently (~85% done) in the midst of a significant refactor which involves some breaking changes, but also has proper type hinting support as a required goal. I hope to get something in master and have atleast a beta release out in the next couple of days, and hopefully wrap up documentation cleanup next weekend. The TL;DR of the breaking changes are:
In most simple cases the apis will not be significantly different from either Given what I've described above regarding breaking changes - if that would be manageable for your code base, I'd love to get some eyes (other than mine 😁) on the 3.x candidate. An example showing a combination of some of these changes: async def georadius(
self,
key,
longitude,
latitude,
radius,
unit=None,
withdist=False,
withcoord=False,
withhash=False,
count=None,
sort=None,
store=None,
store_dist=None,
any=False,
): After: async def georadius(
self,
key: str,
longitude: Union[int, float],
latitude: Union[int, float],
radius: Union[int, float],
unit: Literal[PureToken.M, PureToken.KM, PureToken.FT, PureToken.MI],
withcoord: Optional[bool] = None,
withdist: Optional[bool] = None,
withhash: Optional[bool] = None,
count: Optional[int] = None,
any_: Optional[bool] = None,
order: Optional[Literal[PureToken.ASC, PureToken.DESC]] = None,
store: Optional[str] = None,
storedist: Optional[str] = None,
) -> Union[int, Tuple[Union[str, GeoSearchResult], ...]]: Where
|
All of that sounds great, except I wouldn't drop support for bytes. With some clever typing, I think bytes and strings can coexist fine out of the box. For example, you might parametrize the Also you don't have to use I'd be glad to do a review so ping me. For us performance is very important, so I'd want to ensure the result is still as fast as aredis ;) |
Thanks - that is exactly the kind of feedback I'd love to get. I was toying with making |
Sorry for the delay but I've unfortunately not had much time in the last few weeks to work on this. Having said that I just noticed a major addition in redis-py itself to start adding async support (redis/redis-py#1899) which is making me seriously rethink the usefulness of this project. |
Good to know, however if this is just bringing aioredis 2.0 into redis-py (which is what it looked like the last time I looked), this project can still be useful. aioredis 2.0 was/(probably still) is much slower than aioredis 1.3 or aredis. |
As maintainer of aioredis and also the person who did the redis py migration, having another option in the meantime is great, especially a maintained one. I would simply be careful around adding features; it gets very hectic very fast. Additionally, one of the other aioredis maintainers is refactoring the asyncio portion to improve performance back to original status, but until then this library is quite useful :) |
This is an interesting and difficult point in the life of redis python, especially for asyncio. I will probably have some time the next few weeks to see the type hinting support through. The half baked version so far is in 6ba8675 but I'm indeed starting to feel that this will quickly get out of hand for a single maintainer |
My design goals for the refactoring are:
|
I've merged the current state of type hints / updates to master and made an initial Specifically related to the type hints you can see the WIP docs and the API documentation |
@alisaifee Sorry, I was super busy but I might be able to review soon. |
@Tinche thanks! If you could hold off for a little longer (or keep this in mind while reviewing): I made a significant mistake before merging to master / cutting the rc1 release - which is I slipped non optional multiple arguments as variadic in a lot of methods (which is literally meant to be one of the breaking changes). I'll aim at another rc by end of day. |
FYI I tagged / released |
Closing this as type hints are mostly in place now. |
Hello.
We are currently using aioredis with a ton of internal type stubs for it, but aioredis is kind of in a transitional/crisis period right now. So we would like to switch to aredis/coredis. If I submitted PRs with type annotations for a bunch of methods, would you consider merging them in?
The text was updated successfully, but these errors were encountered: