Skip to content

Fix Python 3.10+ pipe syntax with create_partial #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

devin-ai-integration[bot]
Copy link
Contributor

Fix Python 3.10+ pipe syntax with create_partial

Fixes #1523

Description

This PR fixes an issue where using Python 3.10+ pipe syntax for Union types (str | None) with create_partial method would crash with a TypeError: type 'types.UnionType' is not subscriptable. After this fix, both syntaxes (Union[str, None] and str | None) are supported.

Changes

  • Modified _process_generic_arg to handle types.UnionType from Python 3.10+ properly
  • Modified _wrap_models to handle types.UnionType from Python 3.10+ properly
  • Added tests to verify both syntaxes work correctly

Testing

Added tests that verify the fix works correctly:

  • tests/dsl/test_union_pipe.py - Tests for _process_generic_arg function
  • tests/llm/test_openai/test_pipe_syntax.py - Tests for Partial class with pipe syntax

Link to Devin run: https://app.devin.ai/sessions/42638ce64e364908a91a6ed24cb022d4
Requested by: Jason Liu (work@jxnl.co)

Co-Authored-By: Jason Liu <jason@jxnl.co>
Copy link
Contributor Author

🤖 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

Copy link

cloudflare-workers-and-pages bot commented May 16, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
instructor c20d182 Visit preview May 16 2025, 10:37 PM

@github-actions github-actions bot added bug Something isn't working enhancement New feature or request python Pull requests that update python code size:L This PR changes 100-499 lines, ignoring generated files. labels May 16, 2025
Co-Authored-By: Jason Liu <jason@jxnl.co>
Copy link
Contributor Author

Closing due to inactivity for more than 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request python Pull requests that update python code size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using | breaks with partial streaming
0 participants