Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2926

API can't guarantee objects are not None

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • python
    • None

    Description

      Several objects in the Python API can be constructed with optional arguments. Nothing in their code guarantees those arguments are reified or even aligned. A DataFileWriter, for example, requires a DatumWriter, but does not require a schema. A DatumWriter also does not require a schema. So you can attempt to construct and use a DatumWriter or a DataFileWriter whose schema is always None.

      This and similar bugs are found as I add type hints to these classes. Their types cannot be improved without breaking changes.

      I would like to change the API to avoid this kind of pitfall. In this case, I would like for DataFileWriter to require a writers_schema and to construct its own DatumWriter using that schema. I would like DatumWriter to require a schema as well, and for both of these classes to not allow their schemas to be changed after construction.

      This is technically an API breaking change, but I believe the API is too fragile today.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kojiromike Michael A. Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: