-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Improve type hints of from_url method for async Redis client. #3796
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
Improve type hints of from_url method for async Redis client. #3796
Conversation
- Add return type annotation to Redis.from_url() in client.py - Add parameter and return type annotations to utils.from_url() - Improves type safety and IDE autocomplete support - Resolves MyPy no-untyped-call errors for users
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
|
Hi @cheizdo2-art, thank you for your contribution! We will review your change soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds return type annotations to from_url() methods in the asyncio module to improve type safety and resolve MyPy no-untyped-call errors in strict typing mode.
- Added return type annotation
-> _RedisTto theRedis.from_url()classmethod - Added parameter and return type annotations to the
utils.from_url()helper function - Updated TYPE_CHECKING imports in utils.py to support forward references
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| redis/asyncio/utils.py | Added type annotations to from_url() function and imported Any type |
| redis/asyncio/client.py | Added return type annotation and proper cls parameter typing to Redis.from_url() classmethod |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Hi @cheizdo2-art, can you please fix the linter error? Once it's fixed, I think we can merge this one. |
petyaslavova
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Description
Improve type hints for
from_url()method for Redis client in asyncio module.Motivation
Up until recently,
redis.asyncio.client.Redis.from_url()andredis.asyncio.utils.from_url()lacked return type annotations, causing MyPy to report
no-untyped-callerrors when usedin strict typing mode.
This PR improves type safety and IDE autocomplete support for users of the asyncio Redis client.
Changes
-> "Redis"ofRedis.from_url()classmethod is following the pattern offrom_pool()method return type hint (already changed with a previous commit)from_poolExample Usage (Before/After)
Before (requires type:ignore):