Give user registered types priority when encoding / decoding JSON #2188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User registered types should take priority over default types in Kombu.
Although users can currently override the encoder/decoder for a Kombu registered type by calling
register_type
(for example callingregister_type(Decimal, ...)
in their own code), this doesn't work well when it comes to subclassing. If users currently need to pass subclasses of any Celery registered types (datetime, date, time, Decimal or UUID) they would be forced to either:_encoders
dictionary in the Kombu json module, pop the value for the superclass, add their subclass, and then re-add the superclass.By separating user registered types and Kombu registered types into separate dictionaries, we can always give priority to user registered types instead, which simplifies this process for users (although technically it is a breaking change from existing behaviour).
Solves #1895