Skip to content

Fix argparse round-trip fidelity gaps + packaging (v0.1.3) - #4

Merged
nx10 merged 5 commits into
mainfrom
fix/roundtrip-fidelity
Jul 17, 2026
Merged

Fix argparse round-trip fidelity gaps + packaging (v0.1.3)#4
nx10 merged 5 commits into
mainfrom
fix/roundtrip-fidelity

Conversation

@nx10

@nx10 nx10 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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_abbrev now restored. The load guard checked the attribute on the ArgumentParser class (an instance-only attr, always False), so allow_abbrev=False silently round-tripped back to True.
  • Custom argument groups are reconstructed. They were serialized but never recreated, so --help layout 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.
  • Per-subcommand help text (add_parser(help=...)) is now captured and restored (previously dropped).
  • Multi-value metavar tuples are restored (JSON round-trips them as lists).
  • Forward-compatibility: unknown fields are ignored on load instead of raising TypeError, and ArgumentGroup/MutualExclusionGroup gained field defaults so partial/hand-authored docs (per the published schema) load.

Packaging

  • Add py.typed marker (classifiers already advertised Typing :: Typed); verified present in both wheel and sdist.
  • Single-source the version via hatch dynamic versioning (reads __version__).
  • Drop the redundant License :: OSI Approved classifier (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.3 to trigger the PyPI publish workflow.

nx10 added 5 commits July 17, 2026 16:01
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.
@nx10
nx10 merged commit 21d1530 into main Jul 17, 2026
7 checks passed
@nx10
nx10 deleted the fix/roundtrip-fidelity branch July 17, 2026 20:16
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.

1 participant