confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

Inaccurate documentation for `SerializationContext` `field` parameter regarding `MessageField` usage

Open theodore-evans opened this issue 2 years ago • 0 comments

Description

The SerializationContext class documentation implies that an instance of MessageField can be passed for the field parameter. However, MessageField is not an actual Enum, leading to a discrepancy between documentation and functionality.

How to reproduce

  1. Read the SerializationContext and MessageField class documentation.
  2. Attempt to pass an instance of MessageField to SerializationContext.

Proposed Solutions

  1. Convert MessageField to an actual Enum.
    from enum import Enum, auto
    
    class MessageField(str, Enum):
        NONE = 'none'
        KEY = 'key'
        VALUE = 'value'
    
  2. Update the SerializationContext docstring to clarify the field parameter type.
    """
    Args:
        topic (str): Topic data is being produce to or consumed from.
        field (str): One of the attributes from MessageField, indicating what part of the message is being serialized.
        headers (list): List of message header tuples. Defaults to None.
    """
    

Checklist

N/A

theodore-evans avatar Oct 18 '23 16:10 theodore-evans