Fix argparse round-trip fidelity gaps + packaging (v0.1.3) - #4
Merged
Conversation
Deserialization / round-trip fixes: - Restore allow_abbrev on load. The guard checked the attribute on the ArgumentParser class (an instance-only attr, always False), so a parser built with allow_abbrev=False silently round-tripped back to True. - Reconstruct custom argument groups. Groups were serialized but never recreated, so help layout was lost on load. Default (positionals/options) groups are skipped; groups are display-only so parsing is unaffected. - Capture and restore per-subcommand help text (add_parser(help=...)), which lives on the subparsers action's pseudo-actions and was previously dropped. - Restore multi-value metavar tuples (JSON round-trips them as lists). - Tolerate unknown fields on load so documents from a newer argdump still parse instead of raising TypeError (forward compatibility). Packaging: - Add py.typed marker so downstream type checkers honor the annotations (classifiers already advertised Typing :: Typed). - Fix Homepage/Repository URLs (styx-api -> childmindresearch). - Single-source the version: pyproject reads __version__ from __init__.py via hatch dynamic versioning. Adds regression tests for each and updates schema-v1.json with subparsers_help.
…guards - Skip the auto-created positionals/optionals groups by matching known historical titles too, not just the loading parser's. argparse renamed "optional arguments" -> "options" in 3.10, so a document serialized on an older interpreter previously got a spurious duplicate group on 3.10+. - Give ArgumentGroup/MutualExclusionGroup dataclass fields defaults so partial or hand-authored documents load (the published schema marks these optional). - Drop the redundant "License :: OSI Approved" classifier now that the SPDX license expression is set (PEP 639). - publish-pypi: verify the pushed tag matches __version__ before building, so a mismatch fails fast instead of erroring at upload. - README: uv install, per-command subparser help, and the mutex-in-named-group help-display limitation. Adds a regression test for the legacy default-group-title case.
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
Fixes several round-trip fidelity bugs where a serialized parser did not fully reconstruct, plus packaging cleanup. Bumps to 0.1.3.
All changes are backward-compatible; the format gains one additive field (
subparsers_help).Round-trip fixes
allow_abbrevnow restored. The load guard checked the attribute on theArgumentParserclass (an instance-only attr, alwaysFalse), soallow_abbrev=Falsesilently round-tripped back toTrue.--helplayout was lost. Default (positionals/options) groups are skipped — including the pre-3.10"optional arguments"name — so a doc serialized on an older interpreter doesn't gain a spurious duplicate group. Groups are display-only; parsing is unaffected.add_parser(help=...)) is now captured and restored (previously dropped).metavartuples are restored (JSON round-trips them as lists).TypeError, andArgumentGroup/MutualExclusionGroupgained field defaults so partial/hand-authored docs (per the published schema) load.Packaging
py.typedmarker (classifiers already advertisedTyping :: Typed); verified present in both wheel and sdist.__version__).License :: OSI Approvedclassifier (PEP 639, SPDX expression already set).publish-pypi: verify the pushed tag matches__version__before building.Tests
155 passing (was 142), mypy strict clean, ruff clean. New regression tests cover every fix above.
Release
Merge, then push tag
v0.1.3to trigger the PyPI publish workflow.