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

Re-define TypeCodecBase as an AbstractBaseClass

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.8
    • None
    • None

    Description

      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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: