Skip to content

Fix skip_none parameter propagation to nested objects#657

Merged
yukinarit merged 1 commit into
mainfrom
fix-skip_none
Aug 10, 2025
Merged

Fix skip_none parameter propagation to nested objects#657
yukinarit merged 1 commit into
mainfrom
fix-skip_none

Conversation

@yukinarit

Copy link
Copy Markdown
Owner

The skip_none parameter was not being passed to nested dataclasses, unions, and other serializable objects during serialization. This caused None values in nested objects to still be serialized as null even when skip_none=True was specified.

Changes:

  • Update dataclass serialization calls to pass skip_none parameter
  • Update union template and function calls to support skip_none
  • Update Any type serialization to include skip_none parameter
  • Add comprehensive test coverage for nested skip_none behavior
  • Update code generation tests to match new function signatures

Fixes #651

🤖 Generated with Claude Code

The skip_none parameter was not being passed to nested dataclasses,
unions, and other serializable objects during serialization. This
caused None values in nested objects to still be serialized as null
even when skip_none=True was specified.

Changes:
- Update dataclass serialization calls to pass skip_none parameter
- Update union template and function calls to support skip_none
- Update Any type serialization to include skip_none parameter
- Add comprehensive test coverage for nested skip_none behavior
- Update code generation tests to match new function signatures

Fixes #651

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@yukinarit yukinarit requested a review from Copilot August 10, 2025 17:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes the propagation of the skip_none parameter to nested objects during serialization. Previously, when skip_none=True was specified at the top level, None values in nested dataclasses, unions, and other serializable objects would still be serialized as null instead of being skipped.

  • Updates serialization function signatures to include skip_none parameter
  • Ensures skip_none is passed through to all nested serialization calls
  • Adds comprehensive test coverage for nested skip_none behavior

Reviewed Changes

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

File Description
serde/se.py Updates function templates and renderer methods to pass skip_none parameter to nested serialization calls
tests/test_se.py Updates test kwargs string to include skip_none parameter
tests/test_json.py Adds comprehensive tests for skip_none behavior with nested objects, unions, and lists

Comment thread serde/se.py
res = "None"
elif is_any(arg.type) or is_bearable(arg.type, TypeVar):
res = f"to_obj({arg.varname}, True, False, False, c=typing.Any)"
res = f"to_obj({arg.varname}, True, False, False, skip_none, typing.Any)"

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

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

The function call to to_obj has positional parameters mixed with a keyword-like parameter name skip_none. This inconsistency could lead to confusion. Consider using named parameters for all arguments or ensure the parameter order matches the function signature.

Suggested change
res = f"to_obj({arg.varname}, True, False, False, skip_none, typing.Any)"
res = f"to_obj({arg.varname}, True, False, False, skip_none=skip_none, typing.Any)"

Copilot uses AI. Check for mistakes.
@yukinarit yukinarit merged commit d0e3c1c into main Aug 10, 2025
7 checks passed
@yukinarit yukinarit deleted the fix-skip_none branch August 10, 2025 17:08
@yukinarit yukinarit added the enhancement New feature or request label Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skip_none doesn't propagate into nested @serde objects

2 participants