Skip to content

feat: wire @description to pydantic models#2955

Merged
sxlijin merged 10 commits intocanaryfrom
sam/pydantic-desc
Jan 10, 2026
Merged

feat: wire @description to pydantic models#2955
sxlijin merged 10 commits intocanaryfrom
sam/pydantic-desc

Conversation

@sxlijin
Copy link
Collaborator

@sxlijin sxlijin commented Jan 9, 2026

The original reason we didn't implement this was that when we allow attributes to be derived from expressions, we then lose the ability to codegen expr-derived attributes.

However, there's still significant value in giving users JSON schemas when they're just bare strings, so wire that through.

@description is not implemented on enum fields, because there's no clean way to model those in pydantic.

Fixes #2882

@vercel
Copy link

vercel bot commented Jan 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
promptfiddle Skipped Skipped Jan 10, 2026 4:50am

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: baabb9d41c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 99 to 101
/// {%- if let Some(desc) = desc %}
/// # {{desc}}
/// {%- endif %}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Comment multiline enum descriptions safely

If an enum value description contains a newline (e.g., a long @description split across lines), only the first line is prefixed with # and the remaining lines are emitted as raw code. That produces invalid Python output (the next line is a bare string), which will break imports/tests for enums with multi-line descriptions. Consider using prefix_lines (like docstrings) or otherwise comment/escape all lines of desc before rendering.

Useful? React with 👍 / 👎.

@sxlijin sxlijin enabled auto-merge January 10, 2026 05:01
@sxlijin sxlijin added this pull request to the merge queue Jan 10, 2026
Merged via the queue into canary with commit ff4970a Jan 10, 2026
40 checks passed
@sxlijin sxlijin deleted the sam/pydantic-desc branch January 10, 2026 05:30
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.

[bug] Include @description value in Pydantic type

1 participant