Skip to content

Documentation incorrect on JSON serialization, missing include_metadata argument #665

@penoux

Description

@penoux

Checklist

  • I have included information about relevant versions
  • I have verified that the issue persists when using the master branch of Faust.

Steps to reproduce

The models documentation on dumps() for JSON serializing does not state about the include_metadataargument. This is also the case in Models, Serialization, and Codecs section of the documentation.

>>> class LogEvent(Record, serializer='json'):
...     severity: str
...     message: str
...     timestamp: float
...     optional_field: str = 'default value'
...

>>> event = LogEvent(
...     severity='error',
...     message='Broken pact',
...     timestamp=666.0,
... )
>>> event.dumps()
b'{"severity": "error", "message": "Broken pact", "timestamp": 666.0, "optional_field": "default value", "__faust": {"ns": "__main__.LogEvent"}}'

Expected behavior

Expected behavior as per the actual documentation is:

>>> event.dumps()
b'{"severity": "error", "message": "Broken pact", "timestamp": 666.0, "optional_field": "default value"}'

Actual behavior

The include_metadata=False additional argument is necessary to get the expected behavior. It is undocumented though.

Versions

  • Python version: 3.8.5
  • Faust version: 1.10.4
  • Operating system: MacOS Catalina
  • Kafka version: 2.6.0
  • RocksDB version (if applicable): N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions