Skip to content

fix(python): unwrap alias types in pagination results type annotation#14508

Open
iamnamananand996 wants to merge 2 commits intomainfrom
devin/1775150755-fix-pagination-alias-unwrap
Open

fix(python): unwrap alias types in pagination results type annotation#14508
iamnamananand996 wants to merge 2 commits intomainfrom
devin/1775150755-fix-pagination-alias-unwrap

Conversation

@iamnamananand996
Copy link
Copy Markdown
Contributor

@iamnamananand996 iamnamananand996 commented Apr 2, 2026

Description

Note: This fix has already been merged to main as part of v5.3.1. After rebasing, this PR now has zero diff against main and can be closed.

Fixes a mypy type error in generated pagination endpoints when the results property type is a named alias to a list (e.g., AgreementsList = List[Agreement]).

Discovered via fern-demo/docusign-python-sdk#4 where mypy reported:

Argument "items" to "SyncPager" has incompatible type "list[Agreement] | None"; expected "list[list[Agreement]] | None"

Changes Made

All changes below were independently merged to main as v5.3.1 before this PR could be merged. The branch is now empty.

  • endpoint_function_generator.py: Extended _unwrap_container_types to handle named type references that resolve to alias types. When the pagination results property is a named alias to a list/set, the method now resolves the alias declaration, checks if its resolved type is a container, and recursively unwraps it — producing SyncPager[Agreement, ...] instead of SyncPager[AgreementsList, ...].
  • versions.yml: Added changelog entry for v5.3.1.

Testing

  • Ran seed test --generator python-sdk --fixture pagination — all 3 configurations pass with no generated code changes
  • Pre-commit hooks pass (ruff, ruff-format, etc.)
  • pnpm run check passes
  • All CI checks green (78 pass, including all seed tests and ETE)
  • No new seed fixture added — existing pagination fixtures don't use alias types for results properties. The fix was validated against the real-world docusign SDK.

Reviewer Checklist

  • This PR can be closed — the equivalent fix is already on main (v5.3.1)
  • Verify that the merged v5.3.1 on main correctly handles chained aliases (not just one level of resolution)
  • Consider whether non-container alias resolved types (e.g., alias to a primitive or named type) need handling, or if falling through to return the original type is correct

Link to Devin session: https://app.devin.ai/sessions/c854539c0cc24a0d9627ebf03398dc1c
Requested by: @iamnamananand996

@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@iamnamananand996 iamnamananand996 marked this pull request as ready for review April 2, 2026 17:48
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@devin-ai-integration devin-ai-integration bot force-pushed the devin/1775150755-fix-pagination-alias-unwrap branch from 7edc948 to 7aa50c9 Compare April 3, 2026 18:28
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1775150755-fix-pagination-alias-unwrap branch from 7aa50c9 to 26e1efd Compare April 3, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant