-
Notifications
You must be signed in to change notification settings - Fork 961
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
Make redis dependency optional #869
Conversation
Ping |
Great. So this won't install redis by default, but is there anything that someone using redis should do to install it? Just wondering if there is anything we can document here |
We could catch the import error and display a detailed error message indicating that redis is an optional dependency and must be explicitly installed (clients often expect |
For starters, I added a note to the readme in the latest commit. |
True, exceptionally for this use case of "connectors" we should go with the warning. @ahesford this is how a warning can be raised https://github.com/plamere/spotipy/blob/fa44fed76d7aecb70f9ee6cde14da5e2ce1e17d7/spotipy/client.py#L1951
Thanks that helps. Note that in any case we won't be able to merge this into v2 aka master just now, because it would break existing apps. So this will have to go into v3 https://github.com/plamere/spotipy/tree/v3 |
Rebased on v3. That branch had no redis cache handler at all, so I brought the whole class over. I added an import check during creation of a cache object to make sure redis is available and warn if not. I'm not sure there would be a good way to handle this in the functions where the import are actually needed, unless the exception catching is moved from |
spotipy/cache_handler.py
Outdated
try: | ||
from redis import RedisError | ||
except ImportError: | ||
warnings.warn('Error importing requied module "redis"', UserWarning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here: "requied".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the word "required" may imply to some users that this module is required for the whole package. Instead, the error message should indicate that this module is required for the RedisCacheHandler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. I also restructured the history to preserve the evolution of Redis support on the master branch and diminish the extent of my own changes.
The redis package is only used when somebody uses the redis cache handler, so the imports can be restructured to make redis an optional dependency.