← Back to issue list

feat: add create_grammar_model()

View original Github issue

Metadata

Project
craft-grammar
Number
#21
Type
pull request
State
merged
Author
tigarmo
Labels
—
Created
Updated
Closed

Current evaluation

Merged PR #21 in commit 755aa9b, adding create_grammar_model() to generate Pydantic model code with corresponding Grammar-wrapped field types.

Resolution: closed resolved

Reason: PR #21 was approved and merged in commit 755aa9b. It introduces and publicly exports create_grammar_model() for generating compatible grammar-aware Pydantic model code.

Evaluated by: mr-cal-bot

No scores available.

Issue body

(this builds on top of #20, only the last commit is new) This function creates the Python code for a grammar-aware class that is compatible with the provided parameter (a Pydantic model class). "Compatible" in this case means that the grammar-aware class has the same (annotated) fields as the original class, but with grammar-aware types. For instance, if the source class has a field called "x" whose type is "str", the grammar-aware class will have a field called "x" whose type is "Grammar[str]". We implement support for many common types but this support is not exhaustive yet.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged PR #21 in commit 755aa9b, adding create_grammar_model() to generate Pydantic model code with corresponding Grammar-wrapped field types.
stealth/space-bunny-alpha — closed resolved Merged PR #21 in commit 755aa9b, adding create_grammar_model() to generate Pydantic classes with equivalent fields and Grammar-wrapped types.
stealth/space-bunny-alpha — closed resolved Merged canonical/craft-grammar#21 at 755aa9b, adding create_grammar_model() to generate grammar-aware Pydantic classes with equivalent fields and Grammar[...]-wrapped types.
qwen/qwen3.6-35b-a3b — — Merged create_grammar_model(), generating grammar-aware classes from Pydantic models by converting standard types. Approved by two reviewers, passes CI, and adds 245 lines across four files.

Update history

No update history recorded yet.

Related work

  • Related To: canonical/craft-grammar#20 (confidence 100%)

    PR #21 explicitly builds on the merged Python 3.8 support removal in PR #20.

Related issues

Issue Project State Summary Similarity
#4 models: create grammar-aware pydantic models (CRAFT-856) craft-grammar merged PR #4 by cmatsuoka merged into main as commit 1643465 (branch commit 7e00b4d, +508/-11, 10 files), adding grammar-aware Pydantic models GrammarStr, GrammarStrList and GrammarSingleEntryDictList for lifecycle build-environment.
71%