mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #940] Provide optional Encoder argument to CacheFileHandler #566
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#566
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?
Originally created by @shawncruz on GitHub (Feb 12, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/940
Is your feature request related to a problem? Please describe.
Currently, the
CacheFileHandlerimplementation ofsave_token_to_cachedoesn't include an option for a custom serializer. The problem with this is that every object that's passed in must be serializable by the default JSONEncoder. However, in my use-case, I'm working with an object that has a value type decimal.Decimal, which is not JSON serializable out of the box. For example:Will result in a TypeError:
TypeError: Object of type Decimal is not JSON serializableDescribe the solution you'd like
A clear and concise description of what you want to happen.
Provide an optional argument to
CacheFileHandlercalledencoder_clsthat provides a custom encoder implementation for the token object provided tosave_token_to_cache:Describe alternatives you've considered
An alternative to this is to have the client encode with a custom encoder, then decode before passing into
save_token_to_cache. Thesave_token_to_cachewill then encode a second time: