test: add coverage for tomlkit._types wrapper operators#570
Open
darrenhuai wants to merge 1 commit into
Open
Conversation
_CustomList.__add__/__iadd__, _CustomDict.__or__/__ior__, and the wrap_method helper had no direct tests, leaving tomlkit/_types.py at 60% coverage despite backing the operator overloads on Array and every table type. Notably, __add__ silently returns a plain list (loses the Array wrapper) while __or__ preserves the Table wrapper - this asymmetry is now pinned down by a test instead of being implicit. wrap_method itself is unused elsewhere in the codebase but is part of the public API (exported via __all__), so it's tested directly against a minimal wrapper class. tomlkit/_types.py coverage: 60% -> 100%. Agent: Claude Code Model: claude-sonnet-5 Notes: repo research, coverage-gap analysis, tests, and verification (pytest/ruff/mypy) all done by the agent; reviewed before pushing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tomlkit/_types.pywas sitting at 60% coverage. The uncovered part is_CustomList.__add__/__iadd__,_CustomDict.__or__/__ior__, and thewrap_methodhelper — the machinery everyArrayand table type relies on to get list/dict operator support. None of it had a direct test.While writing these I noticed something worth calling out:
Array + [...]returns a plainlist, not anArray(the.copy()in__add__doesn't preserve the subclass), whereasTable | {...}does come back as aTable. That's existing behavior, not something I changed — I just added a test that pins it down instead of leaving it implicit. Worth a look if that asymmetry wasn't intentional, but out of scope for a coverage PR.wrap_methodisn't called anywhere in the current codebase but is exported in__all__, so I tested it directly against a small stand-in class._types.pycoverage: 60% → 100%. Full suite (1057 tests) still green, ruff and mypy --strict both clean.Agent Drafting Metadata