Skip to content

Conversation

@ericpan64
Copy link
Owner

@ericpan64 ericpan64 commented Oct 29, 2025

Closes N/A

Background

  • Makes the README more clear (removes unused components)
  • Simplifies DSL

Design (high-level)

  • Use function chaining instead of | syntax
  • Add concrete example

Other 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

    • Method chaining in partials: p.get("a.b").join(" ").upper() (pipe syntax still supported).
    • Multi-path extraction: p.get(["name.first", "name.given[*]", "name.suffix"]) with join(flatten=True).
    • Mapper now takes transformations and optional output_schema; accepts Mapping types.
    • Input schemas are metadata only via min_input_schemas/other_input_schemas; auto mode strictness now depends only on output_schema.
    • README rewritten with clearer examples; version bumped to 0.1.5.
  • Migration

    • Replace DataMapping + Mapper with a single Mapper(transformations, output_schema=...).
    • Remove input_schema usage; use min_input_schemas/other_input_schemas for documentation only. No input validation is performed.
    • Update partials where desired to method chaining; p.get can take lists; join supports flatten=True.
    • Remove any imports/references to DataMapping (no longer exported).

- 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
Copy link

@cubic-dev-ai cubic-dev-ai bot left a 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(&#39; ,&#39;)` 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:
Copy link

@cubic-dev-ai cubic-dev-ai bot Oct 29, 2025

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) -&gt; 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>
Fix with Cubic

new_op = (
attr
if not args and not kwargs
else (lambda v: attr(*args, **kwargs)(v))
Copy link

@cubic-dev-ai cubic-dev-ai bot Oct 29, 2025

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(&#39; ,&#39;)` 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) -&gt; 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>
Suggested change
else (lambda v: attr(*args, **kwargs)(v))
else (lambda v: attr.func(v, *args, **kwargs))
Fix with Cubic

@ericpan64 ericpan64 merged commit 554fad4 into main Oct 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants