aioredis-py icon indicating copy to clipboard operation
aioredis-py copied to clipboard

`aioredis.from_url()` is missing type annotation

Open guludo opened this issue 3 years ago • 1 comments

Describe the bug

The function aioredis.from_url() is not type-annotated and that causes checks with mypy --strict to fail in user code.

To Reproduce

  1. Create a file (e.g. foo.py) containing the following:
    import aioredis
    redis = aioredis.from_url('redis://localhost')
    
  2. Check that file with mypy in strict mode (e.g. mypy --strict foo.py). That will cause the following error: error: Call to untyped function "from_url" in typed context.

Expected behavior

The expected behavior is to have mypy approving the example file in strict mode.

Logs/tracebacks

N/A

Python Version

$ python --version
Python 3.10.4

aioredis Version

$ python -m pip show aioredis
Name: aioredis
Version: 2.0.1
Summary: asyncio (PEP 3156) Redis support
Home-page: https://github.com/aio-libs/aioredis-py
Author:
Author-email:
License: MIT
Location: <prefix-removed-by-the-author>/venv/lib/python3.10/site-packages
Requires: async-timeout, typing-extensions
Required-by:

Additional context

No response

Code of Conduct

  • [X] I agree to follow the aio-libs Code of Conduct

guludo avatar Apr 18 '22 20:04 guludo

It looks like it's a few bytes fix... Changing

def from_url(url, **kwargs):

into

def from_url(url: str, **kwargs) -> Redis:

in the utils.py seem to do the job... in a project the only warnings were coming from this function and with the patch it's all fine.

Is there any reason for this to not be done while it looks really trivial?

fdev31 avatar Aug 18 '22 12:08 fdev31