Skip to content

fix(python): infer schemas for bare dict and list annotations - #2317

Merged
guibeira merged 1 commit into
iii-hq:mainfrom
1aifanatic:fix/python-bare-container-schemas
Oct 14, 2026
Merged

guibeira merged 1 commit into
iii-hq:mainfrom
1aifanatic:fix/python-bare-container-schemas

Conversation

@1aifanatic

@1aifanatic 1aifanatic commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Recognize bare dict and list annotations when generating Python function schemas, including nullable forms. The schema keeps the existing behavior for parameterized containers.

Why

Fixes #2194. typing.get_origin(dict) and typing.get_origin(list) return None, so these annotations previously produced no schema.

Notes

  • Added regressions for both Optional spellings and request/response extraction.
  • Before the fix: 7 new regressions failed; after: all 36 format utility tests passed.
  • ruff check and ruff format --check passed for the changed files.

Summary by CodeRabbit

  • Bug Fixes
    • Bare list and dict annotations are now represented correctly in generated schemas, including optional forms. Request and response schemas also handle these annotations correctly.
  • I license my contributions to this repository under Apache 2.0, and I have all necessary rights over the code I am contributing.

@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@1aifanatic is attempting to deploy a commit to the motia Team on Vercel.

A member of the Team first needs to authorize it.

@iii-hq-ci

iii-hq-ci Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

License agreement recorded

@1aifanatic, your agreement has been recorded and you have been added to contributors.md. All future PRs from your account will pass this check automatically.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: iii-hq/iii/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b5c4b47-bb50-4984-afbd-5740efc1a3c2
📥 Commits

Reviewing files that changed from the base of the PR and between b403094 and 8dcbe87.

📒 Files selected for processing: 2
  • sdk/packages/python/iii/src/iii/format_utils.py
  • sdk/packages/python/iii/tests/test_format_utils.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The schema converter now maps bare list and dict annotations to array and object schemas. Tests cover optional forms and request and response schema extraction for a handler.

Changes: Container annotation schemas

Layer / File(s) Summary
Bare container schema handling
sdk/packages/python/iii/src/iii/format_utils.py, sdk/packages/python/iii/tests/test_format_utils.py
Bare list annotations produce array schemas without items, and bare dict annotations produce object schemas without additionalProperties. Tests cover optional annotations and handler request and response schema extraction.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 8dcbe

Bare and nullable list/dict annotations now produce the intended object and array schemas, including in handler extraction. No merge-blocking risk is evident; the change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue #2194 requires schemas for bare dict, bare list, and their nullable forms while preserving parameterized container handling. The change adds annotation is list and annotation is dict che…
Out of Scope Changes check Passed The changes stay within issue #2194. The source change fixes bare container recognition, and the added tests verify the required schemas and extraction behavior. No unrelated change is shown.
Title check Passed The title clearly and concisely describes the main change: schema inference for bare dict and list annotations.
Description check Passed The description includes all required sections: What, Why, and Notes. It explains the change, motivation, tests, formatting checks, and contribution licensing.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@guibeira
guibeira self-requested a review October 14, 2026 11:40
@guibeira

Copy link
Copy Markdown
Contributor

Hey @1aifanatic, thanks for the contribution. Before we move on, can you accept the License agreement required ?

@1aifanatic

Copy link
Copy Markdown
Contributor Author

Confirmed and checked the required license certification on all five PRs (#2317, #2321, #2322, #2323, and #2324). The license checks now pass, and the agreement has been recorded in contributors.md. The remaining Vercel check requires authorization by a member of the motia team.

@guibeira guibeira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @1aifanatic

@guibeira
guibeira merged commit ba6f10e into iii-hq:main Oct 14, 2026
41 of 45 checks passed
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.

format_utils._to_json_schema silently returns None for bare dict / Optional[dict] (and bare list)

2 participants