feat: Text Types#107
Merged
Merged
Conversation
…r extending schemas on demand for logged objects.
Contributor
There was a problem hiding this comment.
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
BaseDataTypetoDataTypeand updated import/handler logic. - Introduced
Text,Markdown, andCodeclasses for rich text rendering and aWithMetahelper for custom metadata. - Extended
serialize()with aschema_extrasparameter 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
formatshadows the built-informatfunction; consider renaming it to something likeformat_hintto improve clarity and avoid confusion.
def __init__(self, text: str, format: str):
dreadnode/data_types/base.py:30
- The docstring for
WithMeta.__init__only describesmetadataand omits explanation of theobjparameter. 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, andCodecorrectly serialize their data and metadata, and thatschema_extrasinserialize()merges as expected.
class Text(DataType):
dreadnode/serialization.py:416
- The special-case for handling
bytesreturn 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()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Text Types
Key Changes:
Added:
Changed:
Removed:
Generated Summary:
CodeandMarkdown, allowing for more descriptive logging.DataTypefor logging different media types, replacing the previousBaseDataType.schema_extrasparameter in theserializemethod for including additional JSON Schema properties.BaseDataTypeclass to streamline the type hierarchy and enforce better encapsulation of behaviors across data types.This summary was generated with ❤️ by rigging