Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1769

Re-define TypeCodecBase as an AbstractBaseClass

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.8
    • 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

            Assignee:
            prashant.mital Prashant Mital (Inactive)
            Reporter:
            prashant.mital Prashant Mital (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: