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

Widen from_dict methods to accept any Mapping #451

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/betterproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Generator,
Iterable,
List,
Mapping,
Optional,
Set,
Tuple,
Expand Down Expand Up @@ -1178,7 +1179,7 @@ def to_dict(
output[cased_name] = value
return output

def from_dict(self: T, value: Dict[str, Any]) -> T:
def from_dict(self: T, value: Mapping[str, Any]) -> T:
"""
Parse the key/value pairs into the current message instance. This returns the
instance itself and is therefore assignable and chainable.
Expand Down Expand Up @@ -1398,7 +1399,7 @@ def to_pydict(
output[cased_name] = value
return output

def from_pydict(self: T, value: Dict[str, Any]) -> T:
def from_pydict(self: T, value: Mapping[str, Any]) -> T:
"""
Parse the key/value pairs into the current message instance. This returns the
instance itself and is therefore assignable and chainable.
Expand Down