Skip to content

Return an empty object when skipkeys drops every key - #122

Merged
dpranke merged 1 commit into
dpranke:mainfrom
GreedyC:codex/skipkeys-empty-indented-object
Oct 14, 2026
Merged

dpranke merged 1 commit into
dpranke:mainfrom
GreedyC:codex/skipkeys-empty-indented-object

Conversation

@GreedyC

@GreedyC GreedyC commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

With skipkeys=True and indent=2, a mapping whose keys are all unsupported is serialized as {\n ,\n}, which cannot be parsed as JSON5.

Return {} when no keys were emitted. The regression covers numeric/string indentation, both trailing-comma settings, and an empty filtered object nested in an array.

Validation on Python 3.14.6: all 81 unit tests, doctests, Ruff, Pylint, Mypy, 100% line coverage, wheel/sdist builds, and Twine checks pass. The regression fails on the unchanged implementation. ./run presubmit exits successfully, but still prints an existing pyproject.toml formatting warning; the same warning was reproduced from the unchanged HEAD file. This PR does not alter that file.

@dpranke
dpranke merged commit 1b0e56a into dpranke:main Oct 14, 2026
8 checks passed
@dpranke

dpranke commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Good catch. Thanks for the fix!

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