fix(cdk): Resolve serpyco-rs issues with Optional type annotations in Python 3.10#451
Closed
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Closed
Conversation
…l type issues Co-Authored-By: Aaron <AJ> Steers <aj@airbyte.io>
Contributor
Author
🤖 Devin AI EngineerOriginal prompt from Aaron: I'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Aaron <AJ> Steers <aj@airbyte.io>
Member
|
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 |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 annotationsto key files with Optional type annotations: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/airbyte-interop-catalog#63, which reverts a workaround in the morph repository.
Requested by Aaron (AJ) Steers (Aaron ("AJ") Steers (@aaronsteers)).
Link to Devin run: https://app.devin.ai/sessions/8d30f3ebc188484a8d64ada18f6d04dc