Mark redis.asyncio as public in top-level __init__.py
Pull Request check-list
Please make sure to review and check all of these items:
- [x] Do tests and lints pass with this change?
- [x] Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
- [x] Is the new or changed code fully tested?
- [x] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
- [x] Is there an example added to the examples folder (if applicable)?
- [x] Was the change added to CHANGES file?
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
Description of change
The top-level __init__.py file for the package imports the asyncio sub-package (not confused with the standard library asyncio) but does not explicitly mark it as public in __all__.
https://github.com/redis/redis-py/blob/0d47d6527a10fb70f8fcfdf8df69ae3b11ec92ef/redis/init.py#L3 https://github.com/redis/redis-py/blob/0d47d6527a10fb70f8fcfdf8df69ae3b11ec92ef/redis/init.py#L58-L89
If you just import redis with the intent to use redis.asyncio, Mypy doesn't seem to care but Pyright certainly does. Pyright will treat this as an unknown symbol, which turns off a lot of developer quality-of-life features in VSCode.
import redis
# Pyright will
r = redis.asyncio.Redis() # reportAttributeAccessIssue: "asyncio" is not a known attribute of module "redis"
I did notice that there's a bare # noqa directive for the from redis import asyncio line but since it's bare, I'm not sure exactly what the directive is silencing. I considered it might be the fact that it's not re-exported but I thought it might also be because that import will shadow the standard library asyncio library and imports can get weird when you have module name collisions with the standard library.
Anyways, those are a lot of words explaining a one-line change that will save 8 characters by only needing to import redis instead of redis.asyncio every time.
If this wasn't the intent of including the from redis import asyncio line in the top-level __init__.py, feel free to close this without merging!
Thanks!