-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
We should subclass TypeCodecBase from abc.ABC because:
- it makes the API clear and unambiguous
- it ensures that the user implements all methods that are needed by the custom type marshaling machinery (classes with abc.abstractmethod s and abc.abstractproperty s that have not been overridden raise an exception upon initialization)
- it allows us to validate certain aspects of the user-implemented type codecs that are otherwise difficult to introspect and/or validate
In order to implement this, we will need to split TypeCodecBase into 2 (or possibly 3) abstract base classes:
- a class to inherit from when defining a type codec that only coverts a custom python type to something BSON understands
- a class to inherit from when defining a type codec that only converts a certain BSON type into a custom python type
- a class to inherit from when defining a codec that implements a 2-way conversion. This can also be achieved by simply inheriting from both of the base classes described above so a decision to introduce it would be based primarily on considerations of user-experience
- is related to
-
PYTHON-1750 Support codec callbacks for simple types
- Closed