Skip to content
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

fix(cdk): Resolve serpyco-rs issues with Optional type annotations in Python 3.10 #451

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 29, 2025

Fixes an issue with serpyco-rs and Optional type annotations in Python 3.10.

Root Cause

The issue occurs because Python 3.10 evaluates type annotations at runtime by default, which causes problems with serpyco-rs when analyzing Optional types. This has been confirmed to be related to generics inheritance and resolution in serpyco-rs (see ermakov-oleg/serpyco-rs#191 and ermakov-oleg/serpyco-rs#138).

Solution

Added from __future__ import annotations to key files with Optional type annotations:

  • airbyte_cdk/models/airbyte_protocol.py
  • airbyte_cdk/models/file_transfer_record_message.py

This makes type annotations be stored as strings rather than being evaluated at runtime, which resolves compatibility issues with serpyco-rs.

Related PR

This PR is paired with airbytehq/morph#63, which reverts a workaround in the morph repository.

Requested by Aaron (AJ) Steers (@aaronsteers).

Link to Devin run: https://app.devin.ai/sessions/8d30f3ebc188484a8d64ada18f6d04dc

Copy link
Contributor Author

🤖 Devin AI Engineer

Original prompt from Aaron:

@Devin - Can you see if you can repro this issue using Python 3.10? Then, can you see if you can mitigate it by adding `from __future__ import annotations` at the top of every file?  <https://github.com/airbytehq/morph/issues/62>
And/or if you can think of anything else to try?

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

@github-actions github-actions bot added the bug Something isn't working label Mar 29, 2025
@aaronsteers
Copy link
Contributor

aside - FYI to Airbyte team: I am actively testing this as a potential fix for:

which has also been raised by PyAirbyte users. It was apparently raised in Slack quite a while ago by our users, but I didn't notice it until this week, since all of my code generally includes the from __future__ import annotations for deferred evaluation.

@devin-ai-integration devin-ai-integration bot changed the title fix(python): Resolve serpyco-rs issues with Optional type annotations in Python 3.10 (do not merge) fix(cdk): Resolve serpyco-rs issues with Optional type annotations in Python 3.10 Mar 29, 2025
Copy link
Contributor Author

Closing this PR as adding 'from future import annotations' doesn't fully resolve the issue. We need to wait for a new serpyco-rs release with the fixes from PR #138.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant