Skip to content

Wrong typing for client parameters in ScriptΒ #3123

Closed

Description

@abbasyadollahi

Version

5.0.1

Platform

Python 3.12.1
macOS 14.3

Description

The arguments referring to a client in the Script class are type annotated to the Redis class, although instances of RedisCluster can also end up being the client. This also applies to the ScriptCommands.register_script function, where it expects self to be a Redis instance, even though I can run this successfully with a RedisCluster client.

Causes the following type error:

Cannot access member "register_script" for type "RedisCluster"
  Could not bind method "register_script" because "RedisCluster" is not assignable to parameter "self"
    "RedisCluster" is incompatible with "Redis" Pylance (reportGeneralTypeIssues)

Code

from redis import Redis
from redis.cluster import RedisCluster

client = Redis("localhost")
script = client.register_script("""return redis.call("SET", KEYS[1], ARGV[1])""")
script(["mykey"], ["myvalue"])

client = RedisCluster("localhost")
script = client.register_script("""return redis.call("SET", KEYS[1], ARGV[1])""")
script(["mykey"], ["myvalue"]) # Type error

Activity

  1. github-actions commented on Mar 15, 2025

    @github-actions
    Contributor

    This issue is marked stale. It will be closed in 30 days if it is not updated.

  2. bcmills commented on Mar 16, 2025

    @bcmills

    Ah, staleness bots: because bugs just go away on their own if you ignore them! πŸ™‰

  3. github-actions commented on Mar 17, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale due to inactivity.
    It will be closed in 30 days if no further activity occurs.
    If you believe this issue is still relevant, please add a comment to keep it open.

  4. petyaslavova commented on Mar 31, 2026

    @petyaslavova
    Collaborator

    Fixed with #3876

  5. arlosnow1231-stack commented on Mar 31, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions