Skip to content

Conversation

@majiayu000
Copy link

Summary

Fixes #3712

Update type annotations in Script, AsyncScript, and their corresponding register_script methods to accept both Redis and RedisCluster types.

Changes

  • Added redis.cluster and redis.asyncio.cluster to TYPE_CHECKING imports
  • Updated Script.__init__ to accept Union["redis.client.Redis", "redis.cluster.RedisCluster"]
  • Updated Script.__call__ client parameter similarly
  • Updated ScriptCommands.register_script self type
  • Made equivalent changes for async versions (AsyncScript, AsyncScriptCommands)

Test

Before fix, mypy showed:

Invalid self argument "RedisCluster" to attribute function "register_script" with type "Callable[[Redis, Union[bytes, str, memoryview[int]]], Script]"

After fix, no such error.

🤖 Generated with Claude Code

Update type annotations in Script, AsyncScript, and their corresponding
register_script methods to accept both Redis and RedisCluster types.

This fixes mypy errors when calling register_script on RedisCluster instances.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jit-ci
Copy link

jit-ci bot commented Dec 10, 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 @majiayu000, thank you for your contribution! We will take a look at it soon.

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.

mypy error: Invalid self argument "RedisCluster" to attribute function "register_script"

2 participants