Skip to content

Conversation

cheizdo2-art
Copy link

Description

Add return type annotations to from_url() methods in asyncio module.

Motivation

Currently, redis.asyncio.client.Redis.from_url() and redis.asyncio.utils.from_url()
lack return type annotations, causing MyPy to report no-untyped-call errors when used
in strict typing mode.

This PR improves type safety and IDE autocomplete support for users of the asyncio Redis client.

Changes

  • Added return type annotation -> _RedisT to Redis.from_url() classmethod
  • Added parameter and return type annotations to utils.from_url() helper
  • Updated TYPE_CHECKING imports in utils.py for forward references

Example Usage (Before/After)

Before (requires type:ignore):

import redis.asyncio as redis

async def connect():
    client = await redis.from_url("redis://localhost")  # type: ignore[no-untyped-call]
After (fully typed):
import redis.asyncio as redis

async def connect():
    client = await redis.from_url("redis://localhost")  # ✅ No type:ignore needed

- 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
Copy link

jit-ci bot commented Oct 12, 2025

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.

@petyaslavova
Copy link
Collaborator

Hi @cheizdo2-art, thank you for your contribution! We will review your change soon.

@petyaslavova petyaslavova requested a review from Copilot October 14, 2025 10:09
Copy link
Contributor

@Copilot Copilot AI left a 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 -> _RedisT to the Redis.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants