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.
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(event_sources): implement Mapping protocol on DictWrapper for better interop with existing middlewares #1516
fix(event_sources): implement Mapping protocol on DictWrapper for better interop with existing middlewares #1516
Changes from 1 commit
c5394f5
9875e22
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: I thought for a long time whether or not to explicitly add the
Mapping
protocol here or to simply implement the missing dunder methods and allow duck-typing to carry the day.In the end, I decided it was better to explicitly add the
Mapping
protocol because, all things being equal, I think it is bad for subclasses of this class to break that protocol. It is good formypy
to warn when an implementer chooses to break the protocol. It should require an explicittype: ignore
comment when choosing to break the protocol.There is one existing class,
StreamRecord
, that breaks the protocol. There are no subclasses ofStreamRecord
and it is used only within the context of aDynamoDBRecord
object. Because there is only one instance of this type breakage, and it is so localized, I markedStreamRecord.keys
astype: ignore
and added a comment and some tests to indicate that this class explicitly breaks theMapping
protocol.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In older days I'd ask to remove it as we're breaking it in
StreamRecord
- I'd take this as an instance ofPracticality Beats Purity
.It's highly unlikely a customer will use
.keys
to get the keys of aStreamRecord
dict given the intent. However, if we do receive any customer complaint we'll consider removing the subclassing.