Skip to content

deprecated_args decorator strips typing #3700

@mharding-hpe

Description

@mharding-hpe

After moving to use redis v6 from v5, mypy began complaining that redis.Redis() was returning type Any. I investigated and pinned down that up through v6.0.0b2, it correctly knew the return type was redis.client.Redis, and starting in v6.0.0, it was Any.

Running mypy on the following script shows the issue:

from typing import reveal_type
import redis

reveal_type(redis.Redis(host="harf", port=100, db=0))

I noticed that the @deprecated_args decorator was added to the redis.client.Redis.__init__() method with this commit that fell in the gap between those two versions. I verified that removing that decorator solved the problem. I then looked at the definition of that decorator, and I can see why it is losing the type information. I have tested a fix for this, and will be opening a PR for consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions