-
Notifications
You must be signed in to change notification settings - Fork 429
fix(event_sources): implement Mapping protocol on DictWrapper for better interop with existing middlewares #1516
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import base64 | ||
import json | ||
from typing import Any, Dict, Optional | ||
from typing import Any, Dict, Iterator, Mapping, Optional | ||
|
||
|
||
class DictWrapper: | ||
class DictWrapper(Mapping): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 In the end, I decided it was better to explicitly add the There is one existing class, There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 It's highly unlikely a customer will use |
||
"""Provides a single read only access to a wrapper dict""" | ||
|
||
def __init__(self, data: Dict[str, Any]): | ||
|
@@ -19,6 +19,12 @@ def __eq__(self, other: Any) -> bool: | |
|
||
return self._data == other._data | ||
|
||
def __iter__(self) -> Iterator: | ||
return iter(self._data) | ||
|
||
def __len__(self) -> int: | ||
return len(self._data) | ||
|
||
def get(self, key: str, default: Optional[Any] = None) -> Optional[Any]: | ||
return self._data.get(key, default) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.