From cbd34370803a537743f6cdcadb9e5893781b137d Mon Sep 17 00:00:00 2001 From: James <50501825+Gobot1234@users.noreply.github.com> Date: Sun, 12 Jul 2020 15:07:27 +0100 Subject: [PATCH] Some minor consistency changes - replace some usages of `==` with `is` - use available constants instead of magic strings for type names Co-authored-by: nat --- src/betterproto/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index b6090d5..8a34a4d 100644 --- a/src/betterproto/__init__.py +++ b/src/betterproto/__init__.py @@ -668,7 +668,7 @@ class Message(ABC): elif t.__origin__ in (list, List): # This is some kind of list (repeated) field. return list - elif t.__origin__ == Union and t.__args__[1] == type(None): + elif t.__origin__ is Union and t.__args__[1] is type(None): # This is an optional (wrapped) field. For setting the default we # really don't care what kind of field it is. return type(None) @@ -748,10 +748,10 @@ class Message(ABC): pos = 0 value = [] while pos < len(parsed.value): - if meta.proto_type in ["float", "fixed32", "sfixed32"]: + if meta.proto_type in [TYPE_FLOAT, TYPE_FIXED32, TYPE_SFIXED32]: decoded, pos = parsed.value[pos : pos + 4], pos + 4 wire_type = WIRE_FIXED_32 - elif meta.proto_type in ["double", "fixed64", "sfixed64"]: + elif meta.proto_type in [TYPE_DOUBLE, TYPE_FIXED64, TYPE_SFIXED64]: decoded, pos = parsed.value[pos : pos + 8], pos + 8 wire_type = WIRE_FIXED_64 else: