Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible types issue for expiretime command #3254

Open
Sanchoyzer opened this issue May 29, 2024 · 0 comments
Open

Incompatible types issue for expiretime command #3254

Sanchoyzer opened this issue May 29, 2024 · 0 comments

Comments

@Sanchoyzer
Copy link

Sanchoyzer commented May 29, 2024

Version: redis==5.0.4, mypy==1.10.0

Platform: Python 3.12 on Ubuntu 23.10

Description:
For some reasons, mypy shows the incompatible types error for the expiretime command in the async case, but this code works fine. What could be the problem?

import asyncio

from redis.asyncio import ConnectionPool, Redis


async def main() -> None:
    pool = ConnectionPool.from_url('redis://localhost:6379/0')
    client = await Redis.from_pool(connection_pool=pool)
    assert isinstance(client, Redis)
    try:
        await client.set('key', 'value', ex=300)
        exp = await client.expiretime('key')  # error: Incompatible types in "await" (actual type "int", expected type "Awaitable[Any]")  [misc]
        assert isinstance(exp, int)
    finally:
        await client.aclose()


if __name__ == '__main__':
    asyncio.run(main())

According to this description: "Redis-py 5.0.0 added a py.typed file, but the inline annotations are incomplete", so perhaps the issue is the built-in annotations
P.S. looks similar to 2399

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

No branches or pull requests

1 participant