gabriel / musehub public
BREAKING task/typing-audit #2 / 4
gabriel · 166 days ago · Apr 12, 2026 · Diff

tooling: add gen_type_contracts.py and regenerate type-contracts.md

Copy AST-based type contract generator from muse/tools/ into musehub/tools/. Run it to produce docs/reference/type-contracts.md from live source (314 types: 5 Enums, 47 TypedDicts, 215 Pydantic Models, 43 ORM Models, 4 Protocols).

The generator is self-contained — no external deps beyond stdlib ast. Run: python3 tools/gen_type_contracts.py --repo . --dirs musehub/ tests/ CI check: python3 tools/gen_type_contracts.py --check

sha256:7415b278906587d150233f06c69d5040dec0fc33140b72ccad39dc02ebc3f286 sha
+43 ~19 symbols
sha256:18a183a0f7e4f3f9b2bf9ae61bea01fe8395d6a9c9a00f1897157abda5125a7a snapshot
+43
symbols added
~19
symbols modified
0
dead code introduced
Semantic Changes 62 symbols
~ tools/gen_type_contracts.py .py 31 symbols added
+ EnumMember class class EnumMember L47–51
+ TypeField class class TypeField L54–60
+ TypeRecord class class TypeRecord L63–76
+ _ENUM_BASES variable variable _ENUM_BASES L92–92
+ _KIND_ANCHOR variable variable _KIND_ANCHOR L340–346
+ _KIND_HEADING variable variable _KIND_HEADING L332–338
+ _PROTOCOL_BASES variable variable _PROTOCOL_BASES L97–97
+ _PYDANTIC_BASES variable variable _PYDANTIC_BASES L93–95
+ _SKIP_DIRS variable variable _SKIP_DIRS L83–89
+ _TYPEDDICT_BASES variable variable _TYPEDDICT_BASES L96–96
+ _base_names function function _base_names L127–135
+ _classify_and_extract class function _classify_and_extract L181–268
+ _enum_table function function _enum_table L362–370
+ _extract_default function function _extract_default L153–178
+ _field_table function function _field_table L349–359
+ _get_docstring function function _get_docstring L111–124
+ _has_tablename function function _has_tablename L138–150
+ _infer_repo_name function function _infer_repo_name L448–451
+ _node_to_str function function _node_to_str L106–108
+ generate_markdown function function generate_markdown L373–440
+ Path import import Path L39–39
+ TypedDict import import TypedDict L40–40
+ annotations import import annotations L32–32
+ argparse import import argparse L34–34
+ ast import import ast L35–35
+ datetime import import datetime L36–36
+ difflib import import difflib L37–37
+ sys import import sys L38–38
+ main function function main L454–562
+ scan_directories function function scan_directories L301–325
+ scan_file function function scan_file L276–298
~ docs/reference/type-contracts.md .md 12 symbols added, 19 symbols modified
+ py`@L3865 section MyModel — `tests/test_api_contracts_section37.py` L3865–3873
+ py`@L3874 section MyModel — `tests/test_api_contracts_section37.py` L3874–3882
+ py`@L3883 section MyModel — `tests/test_api_contracts_section37.py` L3883–3891
+ py` section _WorkerObjectEntry — `musehub/api/routes/wire.py` L983–995
+ py` section _WorkerRegisterRequest — `musehub/api/routes/wire.py` L996–1008
+ py` section _ChildOp — `tests/test_musehub_proposals_touched_symbols.py` L631–641
+ py` section _Delta — `tests/test_musehub_proposals_touched_symbols.py` L642–650
+ py` section _DeltaObjectPayload — `tests/test_wire_compression.py` L670–682
+ py` section _DeltaOp — `tests/test_musehub_proposals_touched_symbols.py` L651–660
+ py` section _RawObjectPayload — `tests/test_wire_compression.py` L683–694
+ py` section _S3GetResponse — `tests/test_storage_backends_section33.py` L661–669
+ py` section _ZlibObjectPayload — `tests/test_wire_compression.py` L695–706
~ py`
~ py`
~ py`
~ py`
~ py`
~ py`
~ py`
~ py`
~ py`

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:7415b278906587d150233f06c69d5040dec0fc33140b72ccad39dc02ebc3f286 --body "your comment"