confluent-kafka-python
confluent-kafka-python copied to clipboard
Inaccurate documentation for `SerializationContext` `field` parameter regarding `MessageField` usage
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
- Read the
SerializationContextandMessageFieldclass documentation. - Attempt to pass an instance of
MessageFieldtoSerializationContext.
Proposed Solutions
- Convert
MessageFieldto an actual Enum.from enum import Enum, auto class MessageField(str, Enum): NONE = 'none' KEY = 'key' VALUE = 'value' - Update the
SerializationContextdocstring to clarify thefieldparameter 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