Repository navigation
fix(python): keep package-root type imports in README async snippet - #18510
Conversation
There was a problem hiding this comment.
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.
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
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 |
Description
Linear ticket: N/A (customer report via #customer-alerts)
The README "Async Client" snippet is built from the sync usage snippet.
extractExtraImportsFromSyncSnippetdrops everyfrom <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 onlyclientClassName. The async snippet then emitsfrom <package> import <AsyncClient>, <those names>.from seed import AsyncSeedPropertyAccessbecomesfrom seed import AsyncSeedPropertyAccess, UserProfile, UserProfileVerification.fix).This is not a breaking change. It only affects README text.
Testing
pnpm seed test --generator python-sdk --skip-scriptson all 10 affected fixtures. All passed, and README diffs are limited to the async import line..fern/metadata.json.