Skip to content

fix(python): keep package-root type imports in README async snippet - #18510

Merged
adidavid014 merged 2 commits into
mainfrom
devin/1793048185-python-readme-async-imports
Oct 26, 2026
Merged

adidavid014 merged 2 commits into
mainfrom
devin/1793048185-python-readme-async-imports

Conversation

@fern-api

@fern-api fern-api Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Linear ticket: N/A (customer report via #customer-alerts)

The README "Async Client" snippet is built from the sync usage snippet. extractExtraImportsFromSyncSnippet drops every from <package> import ... line so it can swap in the async client. If the sync snippet imports the client and request types on the same line (from pkg import Client, Foo, Bar), the types are dropped too, and the async example uses names it never imports. Types imported from submodules were on their own lines, so they survived. That's why only some SDKs showed the bug.

Changes Made

  • ReadmeSnippetBuilder.extractPackageImportNamesFromSyncSnippet: collects the names from package-root import lines in the sync snippet, including parenthesized multi-line imports, and leaves out only clientClassName. The async snippet then emits from <package> import <AsyncClient>, <those names>.
  • Regenerated the affected python-sdk seed READMEs. Only the async import line changes, e.g. from seed import AsyncSeedPropertyAccess becomes from seed import AsyncSeedPropertyAccess, UserProfile, UserProfileVerification.
  • Added an unreleased changelog entry (fix).
  • Updated README.md generator (if applicable)

This is not a breaking change. It only affects README text.

Testing

  • Manual testing completed
    • Ran pnpm seed test --generator python-sdk --skip-scripts on all 10 affected fixtures. All passed, and README diffs are limited to the async import line.
    • Regenerated the reporting customer's config with a patched image. Before the fix, the async README imported only the async client. After the fix, it imports the client plus all 5 types the example uses. No other generated files changed except .fern/metadata.json.

Devin Review

@nitpickybot nitpickybot Bot 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.

AI Review Summary

Targeted fix: package-root imports from the sync snippet are now carried into the async README snippet instead of being dropped wholesale. The approach and regenerated seed fixtures look consistent, and adding the trailing space to packageImportPrefix correctly avoids matching from pkg import_something-style prefixes. Main concerns are around the hand-rolled parenthesized-import parser, which can emit odd output for aliases/comments or unterminated parens.

  • 🟡 1 warning(s)
  • 🔵 1 suggestion(s)

Review Scope

  • Mode: Full pull request
  • Range: Full pull request through 8e9a54a4c6315e193622851dca49663a972a8bfc
  • Current range coverage: Complete
  • Cumulative pull request coverage: Complete

This review is complete for the current scope. Addressing all critical and warning findings above satisfies the review; suggestions are optional. Request another review only if subsequent changes introduce new behavior or materially expand the pull request's scope.

Comment thread generators/python-v2/sdk/src/readme/ReadmeSnippetBuilder.ts Outdated
Comment thread generators/python-v2/sdk/src/readme/ReadmeSnippetBuilder.ts

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 potential issue.

Devin Review

@github-actions

Copy link
Copy Markdown
Contributor

SDK Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-10-26T04:07:22Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
python-sdk square 115s (n=5) 187s (n=5) 115s +0s (+0.0%)

main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-10-26T04:07:22Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-10-26 21:10 UTC

@adidavid014
adidavid014 merged commit 7c596d2 into main Oct 26, 2026
103 of 105 checks passed
@adidavid014
adidavid014 deleted the devin/1793048185-python-readme-async-imports branch October 26, 2026 21:31
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.

2 participants