Skip to content

Commit cbd3437

Browse files
Gobot1234nat-n
andauthored
Some minor consistency changes
- replace some usages of `==` with `is` - use available constants instead of magic strings for type names Co-authored-by: nat <nat.noordanus@gmail.com>
1 parent 2585a07 commit cbd3437

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/betterproto/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def _get_field_default_gen(cls, field: dataclasses.Field) -> Any:
668668
elif t.__origin__ in (list, List):
669669
# This is some kind of list (repeated) field.
670670
return list
671-
elif t.__origin__ == Union and t.__args__[1] == type(None):
671+
elif t.__origin__ is Union and t.__args__[1] is type(None):
672672
# This is an optional (wrapped) field. For setting the default we
673673
# really don't care what kind of field it is.
674674
return type(None)
@@ -748,10 +748,10 @@ def parse(self: T, data: bytes) -> T:
748748
pos = 0
749749
value = []
750750
while pos < len(parsed.value):
751-
if meta.proto_type in ["float", "fixed32", "sfixed32"]:
751+
if meta.proto_type in [TYPE_FLOAT, TYPE_FIXED32, TYPE_SFIXED32]:
752752
decoded, pos = parsed.value[pos : pos + 4], pos + 4
753753
wire_type = WIRE_FIXED_32
754-
elif meta.proto_type in ["double", "fixed64", "sfixed64"]:
754+
elif meta.proto_type in [TYPE_DOUBLE, TYPE_FIXED64, TYPE_SFIXED64]:
755755
decoded, pos = parsed.value[pos : pos + 8], pos + 8
756756
wire_type = WIRE_FIXED_64
757757
else:

0 commit comments

Comments
 (0)