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>
This commit is contained in:
		| @@ -668,7 +668,7 @@ class Message(ABC): | |||||||
|             elif t.__origin__ in (list, List): |             elif t.__origin__ in (list, List): | ||||||
|                 # This is some kind of list (repeated) field. |                 # This is some kind of list (repeated) field. | ||||||
|                 return list |                 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 |                 # This is an optional (wrapped) field. For setting the default we | ||||||
|                 # really don't care what kind of field it is. |                 # really don't care what kind of field it is. | ||||||
|                 return type(None) |                 return type(None) | ||||||
| @@ -748,10 +748,10 @@ class Message(ABC): | |||||||
|                 pos = 0 |                 pos = 0 | ||||||
|                 value = [] |                 value = [] | ||||||
|                 while pos < len(parsed.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 |                         decoded, pos = parsed.value[pos : pos + 4], pos + 4 | ||||||
|                         wire_type = WIRE_FIXED_32 |                         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 |                         decoded, pos = parsed.value[pos : pos + 8], pos + 8 | ||||||
|                         wire_type = WIRE_FIXED_64 |                         wire_type = WIRE_FIXED_64 | ||||||
|                     else: |                     else: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user