Skip to content

feat: Text Types#107

Merged
monoxgas merged 2 commits into
mainfrom
feat/text-types
Jul 17, 2025
Merged

feat: Text Types#107
monoxgas merged 2 commits into
mainfrom
feat/text-types

Conversation

@monoxgas
Copy link
Copy Markdown
Contributor

@monoxgas monoxgas commented Jul 17, 2025

Text Types

Key Changes:

  • Added Text, Markdown, and Code data types for rich text rendering
  • Renamed BaseDataType to DataType
  • Enhanced serialization to support schema extensions

Added:

  • Text class for formatted text with format hints
  • Markdown subclass for markdown-formatted text
  • Code subclass for syntax-highlighted code blocks
  • WithMeta helper for adding metadata to logged objects
  • schema_extras parameter to serialize() function

Changed:

  • BaseDataType → DataType for better naming
  • Updated all data type imports and inheritance
  • Enhanced documentation with new text type examples

Removed:

  • base_data_type.py module (consolidated into base.py)

Generated Summary:

  • Enhanced data type support by introducing specialized text types: Code and Markdown, allowing for more descriptive logging.
  • Correctly implemented a new base class DataType for logging different media types, replacing the previous BaseDataType.
  • Simplified serialization process by adding optional schema_extras parameter in the serialize method for including additional JSON Schema properties.
  • Improved documentation for new text types and updated descriptions in various usage guides to reflect changes in data handling capabilities.
  • Removed deprecated BaseDataType class to streamline the type hierarchy and enforce better encapsulation of behaviors across data types.
  • Consolidated imports that now reference the updated base class while enhancing the maintainability of the codebase.

This summary was generated with ❤️ by rigging

@dreadnode-renovate-bot dreadnode-renovate-bot Bot added area/docs Changes to documentation and guides type/docs Documentation updates and improvements labels Jul 17, 2025
@monoxgas monoxgas requested a review from Copilot July 17, 2025 17:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Enhance Dreadnode’s data serialization by renaming the core base class, adding flexible text types with formatting hints, and extending serialize() to accept additional schema properties.

  • Renamed BaseDataType to DataType and updated import/handler logic.
  • Introduced Text, Markdown, and Code classes for rich text rendering and a WithMeta helper for custom metadata.
  • Extended serialize() with a schema_extras parameter to merge extra JSON Schema properties.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dreadnode/serialization.py Switched handlers to DataType, updated _handle_custom_data_type, and added schema_extras support.
dreadnode/data_types/base.py Added new DataType base class and WithMeta helper, replacing the removed BaseDataType.
dreadnode/data_types/text.py Created Text, Markdown, and Code classes for formatted text types.
dreadnode/data_types/* Updated all media classes (audio, image, table, video, object_3d) to inherit from DataType.
dreadnode/data_types/base_data_type.py Removed legacy BaseDataType module.
dreadnode/data_types/init.py Updated exports to include new text types and WithMeta.
docs/usage/rich-objects.mdx Added examples and docs for Markdown, Code, and generic text types.
docs/usage/data-tracking.mdx Listed formatted text under supported data types.
docs/sdk/serialization.mdx Documented new schema_extras parameter in serialize().
docs/sdk/data_types.mdx Added documentation for Text, Markdown, Code, and WithMeta.
Comments suppressed due to low confidence (4)

dreadnode/data_types/text.py:11

  • [nitpick] The parameter name format shadows the built-in format function; consider renaming it to something like format_hint to improve clarity and avoid confusion.
    def __init__(self, text: str, format: str):

dreadnode/data_types/base.py:30

  • The docstring for WithMeta.__init__ only describes metadata and omits explanation of the obj parameter. Please document both parameters to improve the helper's clarity.
    def __init__(self, obj: t.Any, metadata: dict[str, t.Any]):

dreadnode/data_types/text.py:6

  • Introduce unit tests to verify that Text, Markdown, and Code correctly serialize their data and metadata, and that schema_extras in serialize() merges as expected.
class Text(DataType):

dreadnode/serialization.py:416

  • The special-case for handling bytes return values was removed, which can break DataType implementations that return raw bytes. Please reintroduce the bytes branch, for example:
if isinstance(data, bytes):
    return _handle_bytes(data, _seen, metadata)
    data, metadata = obj.to_serializable()

Comment thread dreadnode/data_types/text.py
@monoxgas monoxgas merged commit e8383ac into main Jul 17, 2025
9 checks passed
@monoxgas monoxgas deleted the feat/text-types branch July 17, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Changes to documentation and guides type/docs Documentation updates and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants