-
Notifications
You must be signed in to change notification settings - Fork 0
Update data mapping ergonomics #7
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
Conversation
- Remove input validation from DataMapping - Input schemas now metadata-only, not enforced - Add Generic type support to DataMapping - Better type safety for output models - Replace input_schema with min/other_input_schemas - Documents expected source models as metadata - Update has_schemas to only check output_schema - Remove input validation helpers and functions
- Remove DataMapping class entirely - Consolidate functionality into Mapper - Merge transformation logic into Mapper - Remove DataMapping from __all__ exports - Simplify Mapper constructor interface - Direct transformations parameter - Update tests to use new Mapper API - Bump version to 0.1.5
- Add .pithy/ to .gitignore - Add .claude* pattern to .gitignore - Excludes Claude-related files from tracking
- Simplifies API with method chaining syntax
- p.get('path').join(' ').upper() vs pipe operators
- Adds multi-path extraction to get() function
- get(['path1', 'path2']) returns combined values
- Enhances join() with flatten parameter
- Flattens nested lists and filters None values
- Updates README with cleaner example code
- Removes DataMapping wrapper requirement
- Changes Mapper to accept Mapping interface
- Rewrites README for better clarity and brevity - Removes verbose explanations and comments - Streamlines code examples - Reorganizes feature table with clearer descriptions - Simplifies Table/DataFrame section with examples - Condenses motivation section into design philosophy - Focuses on practical benefits over theory
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.
2 issues found across 13 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="chidian/mapper.py">
<violation number="1" location="chidian/mapper.py:152">
Short-circuiting flexible mode without an output schema bypasses _execute_flexible, so transform exceptions now raise instead of being captured as ValidationIssues. Please route this case through _execute_flexible to preserve flexible-mode error handling.</violation>
</file>
<file name="chidian/partials.py">
<violation number="1" location="chidian/partials.py:68">
Passing arguments to chainable methods like `strip(' ,')` throws a TypeError because `attr(*args, **kwargs)` calls descriptors without the value. Wrap the call so the value becomes the first argument.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| if self._backward_compat and not self.data_mapping.has_schemas: | ||
| return self.data_mapping.transform(data) | ||
| # For non-schema mode, just return dict | ||
| if not self.has_schemas and self.mode == ValidationMode.FLEXIBLE: |
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.
Short-circuiting flexible mode without an output schema bypasses _execute_flexible, so transform exceptions now raise instead of being captured as ValidationIssues. Please route this case through _execute_flexible to preserve flexible-mode error handling.
Prompt for AI agents
Address the following comment on chidian/mapper.py at line 152:
<comment>Short-circuiting flexible mode without an output schema bypasses _execute_flexible, so transform exceptions now raise instead of being captured as ValidationIssues. Please route this case through _execute_flexible to preserve flexible-mode error handling.</comment>
<file context>
@@ -107,9 +148,9 @@ def __call__(self, data: Any) -> Any | MapperResult:
- if self._backward_compat and not self.data_mapping.has_schemas:
- return self.data_mapping.transform(data)
+ # For non-schema mode, just return dict
+ if not self.has_schemas and self.mode == ValidationMode.FLEXIBLE:
+ return self.transform(data)
</file context>
| new_op = ( | ||
| attr | ||
| if not args and not kwargs | ||
| else (lambda v: attr(*args, **kwargs)(v)) |
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.
Passing arguments to chainable methods like strip(' ,') throws a TypeError because attr(*args, **kwargs) calls descriptors without the value. Wrap the call so the value becomes the first argument.
Prompt for AI agents
Address the following comment on chidian/partials.py at line 68:
<comment>Passing arguments to chainable methods like `strip(' ,')` throws a TypeError because `attr(*args, **kwargs)` calls descriptors without the value. Wrap the call so the value becomes the first argument.</comment>
<file context>
@@ -44,9 +44,52 @@ def __len__(self) -> int:
+ new_op = (
+ attr
+ if not args and not kwargs
+ else (lambda v: attr(*args, **kwargs)(v))
+ )
+ return FunctionChain(*self.operations, new_op)
</file context>
| else (lambda v: attr(*args, **kwargs)(v)) | |
| else (lambda v: attr.func(v, *args, **kwargs)) |
Closes N/A
Background
Design (high-level)
|syntaxOther notes
Summary by cubic
Streamlines the data mapping API by removing DataMapping, consolidating functionality into Mapper, and adding ergonomic method chaining and multi-path extraction in partials. This reduces boilerplate and makes transformations easier to read.
New Features
Migration