mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 08:35:49 +03:00
[PR #630] [MERGED] Add deprecation warnings to direct users towards using cache_handler #970
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#970
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/spotipy-dev/spotipy/pull/630
Author: @tonyaajjackson
Created: 12/30/2020
Status: ✅ Merged
Merged: 1/13/2021
Merged by: @stephanebruckert
Base:
master← Head:master📝 Commits (10+)
7afe673Refactor functions into static methods of AuthBase5a48891Create CacheHandler to abstract caching tokens0f201b6Merge branch 'master' of github.com:plamere/spotipyb824d6dFix cache_handler subclass check for Python 2a4ad2dbSplit assert message to fix line over max length9d8c455Split cache handlers into cache_handler.py58d46ebflake8 and autopep fixesdb17532Fix init to allow importing CacheHandler5a5970cflake8 fix62af92bMerge remote-tracking branch 'upstream/master'📊 Changes
4 files changed (+185 additions, -17 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
examples/app.py(+12 -8)📝
spotipy/oauth2.py(+121 -9)📝
tests/unit/test_oauth.py(+51 -0)📄 Description
When
cache_pathorusernameare specified in the constructors of theSpotifyOAuth,SpotifyPKCE, orSpotifyImplicitGrantauth_managers, the constructor creates aCacheFileHandlerinstance under the hood and sets it as the auth_manager'scache_handler. The user is currently able to create aCacheFileHandlerinstance in two ways:cache_handler(new approach)cache_pathandusernameto the auth_manager constructor (old approach)Ideally, there would be one and only one obvious way to specify a CacheFileHandler instance. Specifying by passing to the
cache_handlerallows flexibility in whichCacheHandleris used and should be preferred, so passing thecache_pathorusernameto the auth_manager constructor should be deprecated.This pull request adds deprecation warnings for if
cache_handlerorusernameare passed as arguments toSpotifyOAuth,SpotifyPKCE, orSpotifyImplicitGrant. In addition, the flask example is updated to use thecache_handlerapproach. I did not find other examples that used thecache_pathorusernamearguments to the auth_manager constructors.In addition, in
github.com/plamere/spotipy@9550c8fd86I accidentally broke the caching functionality in theSpotifyOAUth,SpotifyPKCE, andSpotifyImplicitGrantauth_managers by removing theget_cached_tokenand_save_token_infomethods from the auth_manager classes. Users with existing codebases that use theget_cached_tokenand_save_token_infomethods directly will experience errors if they upgrade spotipy.This pull request restores the
get_cached_tokenand_save_token_infomethods on the three auth_manager classes as aliases for the corresponding methods in thecache_handler. Deprecation warnings are also added to theget_cached_tokenand_save_token_infomethods to direct users to switch to using the newcache_handlerapproach. "Legacy" tests checking theget_cached_tokenand_save_token_infomethods in the auth_managers are also added to ensure that the old functionality is preserved.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.