fix: typing for updated datasets and relations Protocols #2870
Merged
Conversation
✅ Deploy Preview for dlt-hub-docs canceled.
|
rudolfix
approved these changes
Jul 13, 2025
Collaborator
rudolfix
left a comment
There was a problem hiding this comment.
LGTM!
we have Protocols mostly to hide implementation details in concrete classes. several functions should not be exposed to end user or we are still not sure if that is the final form
Collaborator
|
@sh-rp should look here as well! |
Collaborator
|
Thanks @zilto for fixing this! My plan was to allow any object that conforms to "Relation" to be able to be consumed in the transformations, but probably nobody is going to implement their own Relation anyway at this point so for me this is good. |
sh-rp
approved these changes
Jul 14, 2025
zilto
added a commit
that referenced
this pull request
Jul 22, 2025
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.
Description
Follow-up to this discussion
typing.Protocol(source, reported by pylance in the screenshots I shared in the previous discussion).Relationwas inadvertently not aProtocol. Similarly, some tests were making assumptions againstRelationwithisinstance()calls (which wouldn't be possible if it was a proper protocol).DataAccesswas implementing method such as__init__and property setters, which is not possible on aProtocol. To maintain the desired approach, I created aDBApiCursorProtocolthat is inherited by the abstract base classDBApiCursor.elseblock afterif TYPE_CHECKINGfrom __future__ import annotationsto avoid circular importsAdditional context
I still in favor of removing this abstraction layer as long as we have a single set of
DatasetandRelationimplementations. Having to modify their superclass / protocols makes maintenance more complex