Skip to content

fix: make orientation optional in async generate() - #174

Merged
davidhu2000 merged 2 commits into
mainfrom
fix/async-generate-optional-orientation
Sep 24, 2026
Merged

davidhu2000 merged 2 commits into
mainfrom
fix/async-generate-optional-orientation

Conversation

@davidhu2000

Copy link
Copy Markdown
Contributor

Problem

Async text_to_video.generate() and ai_image_generator.generate() required orientation. It's deprecated in favor of aspect_ratio, and the sync generate() and both create() methods already treat it as optional.

Root cause

codemod/check_generate_create_sync.py compared only param names between generate() and create(). When the SDK generator made orientation optional in create() (#113, #114), the sync generate() got updated but the async one didn't. Since the name was still there, the check passed.

The same gap left other generate() params stale after later generator updates:

resource sync async
text_to_video model, resolution model, resolution, orientation
ai_image_generator model, resolution model, resolution, orientation
image_to_video model, resolution model, resolution
ai_image_editor model, resolution model, resolution
ai_video_editor model model
ai_image_upscaler style (required, optional in create) style

For example, generate(model="wan-3.0") or generate(model="krea-2") failed mypy even though create() accepts them.

Fix

  • The codemod now also flags shared params whose type or default differs from create() (whitespace and trailing commas are normalized). --fix replaces the definition with the one from create() and keeps its position.
  • The client changes come from python codemod/check_generate_create_sync.py --fix. Nothing was hand-edited, and a second --fix run produces no diff.
  • Changed the CI PR comment to say "run --fix".
  • Async README custom-docs examples for these two tools now use aspect_ratio="16:9" instead of orientation.

Verification

  • python codemod/check_generate_create_sync.py: no issues
  • pytest: 167 passed
  • mypy magic_hour: no issues
  • mypy on a README-style snippet that calls sync and async generate() without orientation: passes here, and fails on main with Missing named argument "orientation" (2 errors)

🤖 Generated with Claude Code

davidhu2000 and others added 2 commits September 23, 2026 21:04
check_generate_create_sync.py only compared param names between
generate() and create(), so when the SDK generator changed a param's
type/default in create(), generate() kept the stale definition. The
codemod now also flags drifted definitions and --fix copies them from
create(). Client changes are the codemod's --fix output.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@davidhu2000
davidhu2000 merged commit 3716b39 into main Sep 24, 2026
6 checks passed
@davidhu2000
davidhu2000 deleted the fix/async-generate-optional-orientation branch September 24, 2026 04:09
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