Skip to content

Implement Message.__bool__ #138

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

Closed
wants to merge 22 commits into from
Closed
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3dd65af
Implement Message.__bool__
Gobot1234 Aug 14, 2020
50051c9
Update src/betterproto/__init__.py
Gobot1234 Aug 16, 2020
aad9084
Fix stuff
Gobot1234 Aug 16, 2020
114a02f
Blacken
Gobot1234 Aug 16, 2020
ac197fd
Blacken for real
Gobot1234 Aug 16, 2020
6e08097
Fix: to_dict returns wrong enum fields when numbering is not consecut…
boukeversteegh Jul 12, 2020
c41516c
Improve poetry install speed by first upgrading pip
boukeversteegh Jul 11, 2020
3102b06
Some minor consistency changes
Gobot1234 Jul 12, 2020
e192c70
REF: Refactor plugin.py to use modular dataclasses in tree-like struc…
adriangb Jul 25, 2020
56e7b98
Fix the readme gRPC usage example (#122)
theunkn0wn1 Jul 25, 2020
eda8035
Serialize default values in oneofs when calling to_dict() or to_json(…
bradykieffer Jul 25, 2020
94e7acc
Replace Makefile with poe tasks in pyproject.yaml (#118)
nat-n Jul 25, 2020
6e99e45
grpclib_client: handle trailer-only responses (#127)
abn Jul 25, 2020
9d6904c
Fix static type checking for grpclib client (#124)
abn Jul 30, 2020
230f58b
Support deprecated message and fields (#126)
abn Jul 30, 2020
38c7d1b
ci: refactor jobs and improve platform coverage (#128)
abn Jul 30, 2020
37562d3
Update poe (#132)
nat-n Aug 6, 2020
c5afae4
Improve logic to avoid keyword collisions in generated code
Gobot1234 Aug 9, 2020
bf0ca78
Factor code template compilation out into a separate module
adriangb Aug 9, 2020
42a1d7f
Small improvements to models.py
adriangb Aug 23, 2020
07f010b
Implement for #130
Gobot1234 Aug 24, 2020
5ba4ba1
Merge branch 'master' into messagebool
Gobot1234 Aug 24, 2020
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
6 changes: 6 additions & 0 deletions src/betterproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ def __setattr__(self, attr: str, value: Any) -> None:

super().__setattr__(attr, value)

def __bool__(self) -> bool:
return any(
getattr(self, field_name)
for field_name in self._betterproto.meta_by_field_name
)

@property
def _betterproto(self):
"""
Expand Down