Skip to content

✨ Rename the dump-side tags= registry to serializers=#222

Merged
frenck merged 2 commits into
mainfrom
frenck/rename-dump-serializers
Jul 5, 2026
Merged

✨ Rename the dump-side tags= registry to serializers=#222
frenck merged 2 commits into
mainfrom
frenck/rename-dump-serializers

Conversation

@frenck

@frenck frenck commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Breaking change

Yes. The dump-side registry keyword argument is renamed from tags to serializers on dumps, dump, and async_dump. Code that passed a type-keyed registry to dump now needs the new name:

# before
yamlrocks.dumps(obj, tags={MyType: lambda o: yamlrocks.YAMLRocksTag("!t", o.x)})
# after
yamlrocks.dumps(obj, serializers={MyType: lambda o: yamlrocks.YAMLRocksTag("!t", o.x)})

There is no deprecation alias: the old tags= on dump now raises TypeError. This is intentional, done before 1.0 so the name never has to be carried forward. The load-side tags= (keyed by YAML tag string) is unchanged.

Proposed change

On load, tags is keyed by the YAML tag string ({"!vec": func}): "when you see this tag, transform the value." On dump, the same-named argument was keyed by Python type ({MyType: func}): "when you see this type, emit it like this." One name covered two different registries keyed by two different things, which read as a symmetry that was not real.

Renaming the dump side to serializers reflects what it actually does (turn a Python object into something emittable) and reveals the true parallel: each side has a registry plus a catch-all.

load:  tags=         (by YAML tag)      + tag_handler=  (catch-all)
dump:  serializers=  (by Python type)   + default=      (catch-all)

This is part of the pre-1.0 API-surface review: freezing a clearer surface now rather than a confusing one later. The internal EncodeCtx.tags field is left as-is (private, not user-visible).

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to:
  • Link to a separate documentation pull request:

Checklist

  • I have read the AI Policy, and this pull request was not created by an autonomous agent.
  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and uv run pytest passes locally. A pull request cannot be merged unless CI is green.
  • uv run ruff check . and uv run ruff format --check . pass.
  • cargo fmt --check and cargo clippy --all-targets -- -D warnings pass.
  • Round-trip fidelity is preserved: an unmodified document still re-emits byte-for-byte.
  • No commented-out or dead code is left in the pull request.

If the change is user-facing:

  • Documentation under docs/ is added or updated, and docs/verify_examples.py still passes.

Copilot AI review requested due to automatic review settings July 5, 2026 12:49
@frenck frenck added the breaking-change A breaking change for existing users. label Jul 5, 2026
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@frenck, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1c7cc083-e8e2-4bc2-ac1e-d18290e31f2f

📥 Commits

Reviewing files that changed from the base of the PR and between 7d18b46 and f2196f7.

📒 Files selected for processing (1)
  • tests/features/test_tags.py
📝 Walkthrough

Walkthrough

This pull request renames the tags keyword parameter to serializers in the dumps()/dump()/async_dump() APIs, which register callables for emitting custom YAML tags on Python types. Changes span the Rust FFI implementation (PyO3 signature and EncodeCtx construction), the Python wrapper functions, the .pyi type stubs, API reference and guide documentation, and the test suite covering registry-based serialization behavior, tuple returns, dataclass precedence, exact-type matching, error handling, and tag whitespace validation.

Changes

Cohort / File(s) Summary
Rust FFI (src/ffi/mod.rs) Renamed tags parameter to serializers in dumps() PyO3 signature; EncodeCtx.tags now sourced from serializers
Python wrapper (pysrc/yamlrocks/__init__.py) dump() and async_dump() accept serializers instead of tags; forwarding calls updated
Type stubs (pysrc/yamlrocks/__init__.pyi) dump, dumps, async_dump stub signatures renamed tags to serializers
Docs (docs/src/content/docs/reference/api.md, docs/src/content/docs/guides/tags.md) API reference and guide text/examples updated to use serializers
Tests (tests/features/test_tags.py) Renamed and updated tests to use serializers= argument

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant async_dump
  participant dump
  participant dumps_rs as dumps (Rust FFI)
  participant EncodeCtx

  Caller->>async_dump: async_dump(obj, serializers={...})
  async_dump->>dump: dump(obj, serializers=serializers)
  dump->>dumps_rs: dumps(obj, serializers=serializers)
  dumps_rs->>EncodeCtx: tags = serializers.as_ref()
Loading

Related issues: None specified.

Related PRs: None specified.

Suggested labels: documentation, breaking-change, api

Suggested reviewers: frenck

🐰

A tag by any other name,
still marks the YAML just the same,
from tags to serializers we hop,
through Rust and Python, non-stop,
the docs now sing the renamed refrain.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: renaming the dump-side registry from tags= to serializers=.
Description check ✅ Passed The description accurately explains the breaking rename, migration impact, and rationale, and matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Jul 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing frenck/rename-dump-serializers (f2196f7) with main (d956d9c)

Open in CodSpeed

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
tests/features/test_tags.py (2)

221-229: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Stale tags in test function name.

Docstring/body now describe the serializers callback, but the function name still says test_dumps_tags_callback_bad_return_raises, inconsistent with the sibling renames (test_dumps_serializers_registry_*).

✏️ Suggested rename
-def test_dumps_tags_callback_bad_return_raises():
+def test_dumps_serializers_callback_bad_return_raises():

141-263: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing regression test for the breaking-change contract.

Per the PR objectives, passing the old tags= keyword to dumps/dump/async_dump should now raise TypeError with no deprecation alias. None of the updated tests assert this; consider adding one to lock in the intentional break and guard against a future accidental re-introduction of the old kwarg alias.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 83902994-0baa-4d7a-b00a-2e66b91afe5f

📥 Commits

Reviewing files that changed from the base of the PR and between d956d9c and 7d18b46.

📒 Files selected for processing (6)
  • docs/src/content/docs/guides/tags.md
  • docs/src/content/docs/reference/api.md
  • pysrc/yamlrocks/__init__.py
  • pysrc/yamlrocks/__init__.pyi
  • src/ffi/mod.rs
  • tests/features/test_tags.py

@codecov-commenter

codecov-commenter commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.51%. Comparing base (9122a96) to head (f2196f7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #222   +/-   ##
=======================================
  Coverage   92.51%   92.51%           
=======================================
  Files          41       41           
  Lines       12720    12720           
=======================================
  Hits        11768    11768           
  Misses        952      952           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 PR renames the dump-side registry keyword argument from tags to serializers across the public API (dumps, dump, async_dump), the type stubs, the documentation, and the tests. The motivation is a pre-1.0 API-surface cleanup: the load-side tags= is keyed by YAML tag string while the dump-side argument was keyed by Python type, so a single shared name implied a symmetry that did not exist. serializers= better describes turning a Python object into an emittable representation and exposes the true parallel (tags/tag_handler on load vs. serializers/default on dump). The internal EncodeCtx.tags field is intentionally left unchanged, and the load-side tags= is unaffected. This is an intentional breaking change with no deprecation alias.

Changes:

  • Renamed the dump-side keyword-only argument tagsserializers in the PyO3 dumps signature and in the pure-Python dump/async_dump wrappers and .pyi stubs.
  • Mapped the public serializers argument onto the existing internal EncodeCtx.tags field, leaving encoder internals untouched.
  • Updated the tags guide, API reference, and test_tags.py to use serializers=.

Reviewed changes

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

Show a summary per file
File Description
src/ffi/mod.rs Renames the dumps keyword tagsserializers and forwards it into EncodeCtx.tags; updates the ignored-args comment.
pysrc/yamlrocks/__init__.py Renames the dump/async_dump keyword and its forwarding to dumps/dump.
pysrc/yamlrocks/__init__.pyi Updates the dump-side stub signatures to serializers; load-side tags preserved.
docs/src/content/docs/reference/api.md Documents serializers for dumps/dump.
docs/src/content/docs/guides/tags.md Rewrites the "emit your own types" section and examples to use serializers.
tests/features/test_tags.py Renames dump-side registry tests and updates docstrings/examples to serializers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/features/test_tags.py Outdated
@frenck frenck merged commit 64abe27 into main Jul 5, 2026
73 checks passed
@frenck frenck deleted the frenck/rename-dump-serializers branch July 5, 2026 13:47
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

breaking-change A breaking change for existing users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants