Skip to content

Pylance type checking issues with async redis.hset #3169

Open
@epicwhale

Description

@epicwhale

Version: What redis-py and what redis version is the issue happening on?
5.0.2

Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure)
3.12

Description: Description of your issue, stack traces from errors and code that reproduces the issue

Pylance throws a type checking issue while trying to use await with hset using a redis.asyncio.client.Redis instance

"int" is not awaitable
  "int" is incompatible with protocol "Awaitable[_T_co@Awaitable]"
    "__await__" is not presentPylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)
(method) def hset(
    name: str,
    key: str | None = None,
    value: str | None = None,
    mapping: dict[Unknown, Unknown] | None = None,
    items: list[Unknown] | None = None
) -> (Awaitable[int] | int)
import redis.asyncio as aio_redis
pool = aio_redis.ConnectionPool.from_url(
    f"redis://{settings.redis_host}:{settings.redis_port}/{settings.redis_db}"
)
client = await aio_redis.Redis.from_pool(pool)

await client.hset(key, field, publish_data_json)  # <--- pylance type check error here

Is this working as intended?

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