- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
          Drop (Concise)TreeSchemas, use pydantic TypeAdapter instead; Remove marshmallow dependency; Drop Python 3.9 support (breaking)
          #685
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…tead (breaking) Instead of `TreeSchema().dump(t)` use `model_dump_tree(t)`. Instead of `ConciseTreeSchema().dump(t)` use `model_dump_tree(t, mode="concise")` Instead of `ConciseConditionKeyTreeSchema().dump(t)` use `model_dump_tree(t, mode="compress-conditions-only")`. finally fixes #478
…dDict` instead of `typing.TypedDict` on Python < 3.12.
https://peps.python.org/pep-0613/ Python 3.9 EOL is near anyways.
TreeSchemas, use pydantic TypeAdapter instead (breaking)TreeSchemas, use pydantic TypeAdapter instead; Remove marshmallow dependency; Drop 3.9 support (breaking)
      TreeSchemas, use pydantic TypeAdapter instead; Remove marshmallow dependency; Drop 3.9 support (breaking)TreeSchemas, use pydantic TypeAdapter instead; Remove marshmallow dependency; Drop Python 3.9 support (breaking)
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates from marshmallow to pydantic for JSON serialization of tree structures, replaces the deprecated TreeSchema, ConciseTreeSchema, and ConciseConditionKeyTreeSchema classes with a single model_dump_tree() function using pydantic's TypeAdapter, and drops support for Python 3.9.
Key changes:
- Replaced marshmallow-based schemas with pydantic TypeAdapterand custom serialization functions
- Introduced model_dump_tree()function with mode parameter to handle different serialization behaviors
- Removed Python 3.9 support (minimum now 3.10) to enable use of TypeAlias
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description | 
|---|---|
| unittests/test_tree_schemas.py | Updated test imports and replaced schema .dump()calls withmodel_dump_tree()function calls | 
| unittests/test_json_serialization.py | Simplified _test_serialization_roundtripto remove marshmallow path and schema parameter | 
| src/ahbicht/json_serialization/tree_schema.py | Replaced marshmallow schemas with pydantic TypeAdapter-based serialization using custom serializers | 
| src/ahbicht/json_serialization/concise_tree_schema.py | Deleted file - functionality moved to tree_schema.py | 
| src/ahbicht/json_serialization/concise_condition_key_tree_schema.py | Deleted file - functionality moved to tree_schema.py | 
| pyproject.toml | Updated minimum Python to 3.10, removed marshmallow dependency and Python 3.9 classifier | 
| json_schemas/generate_json_schemas.py | Removed marshmallow schema generation path, keeping only pydantic approach | 
| .github/workflows/unittests.yml | Removed Python 3.9 from test matrix | 
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def model_dump_tree( | ||
| tree: Tree, mode: Literal["json", "concise", "compress-conditions-only"] = "json" | ||
| ) -> dict[str, Any]: | ||
| """ahbicht v1 replacement for the removed TreeSchema""" | 
    
      
    
      Copilot
AI
    
    
    
      Oct 28, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring should describe what this function does and document the parameters and return value, not just state it's a replacement. Add a proper docstring with parameter descriptions for 'tree' and 'mode', plus return value documentation.
| """ahbicht v1 replacement for the removed TreeSchema""" | |
| """ | |
| Serializes a Lark Tree object into a dictionary suitable for JSON serialization. | |
| Parameters: | |
| tree (Tree): The Lark Tree object to serialize. | |
| mode (Literal["json", "concise", "compress-conditions-only"], optional): | |
| The serialization mode. | |
| - "json": Standard JSON serialization of the tree. | |
| - "concise": Returns a compressed version of the tree. | |
| - "compress-conditions-only": Compresses only condition key nodes in the tree. | |
| Defaults to "json". | |
| Returns: | |
| dict[str, Any]: The serialized representation of the tree, as a dictionary. | |
| Raises: | |
| ValueError: If an unsupported mode is provided. | |
| """ | 
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Instead of
TreeSchema().dump(t)usemodel_dump_tree(t).Instead of
ConciseTreeSchema().dump(t)usemodel_dump_tree(t, mode="concise")Instead of
ConciseConditionKeyTreeSchema().dump(t)usemodel_dump_tree(t, mode="compress-conditions-only").Python 3.9 EOL is end of this month and 3.9 didn't have TypeAlias yet.
finally fixes #478