From 04dce524aaf0caa919ec7c72cb9da40b1aec6dd1 Mon Sep 17 00:00:00 2001 From: James Lan Date: Thu, 11 Jun 2020 22:23:45 -0700 Subject: [PATCH] fixed field types should be int --- betterproto/plugin.py | 4 ++-- betterproto/tests/inputs/fixed/fixed.json | 6 ++++++ betterproto/tests/inputs/fixed/fixed.proto | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 betterproto/tests/inputs/fixed/fixed.json create mode 100644 betterproto/tests/inputs/fixed/fixed.proto diff --git a/betterproto/plugin.py b/betterproto/plugin.py index c843a6a..c867930 100755 --- a/betterproto/plugin.py +++ b/betterproto/plugin.py @@ -103,9 +103,9 @@ def py_type( message: DescriptorProto, descriptor: FieldDescriptorProto, ) -> str: - if descriptor.type in [1, 2, 6, 7, 15, 16]: + if descriptor.type in [1, 2]: return "float" - elif descriptor.type in [3, 4, 5, 13, 17, 18]: + elif descriptor.type in [3, 4, 5, 6, 7, 13, 15, 16, 17, 18]: return "int" elif descriptor.type == 8: return "bool" diff --git a/betterproto/tests/inputs/fixed/fixed.json b/betterproto/tests/inputs/fixed/fixed.json new file mode 100644 index 0000000..8858780 --- /dev/null +++ b/betterproto/tests/inputs/fixed/fixed.json @@ -0,0 +1,6 @@ +{ + "foo": 4294967295, + "bar": -2147483648, + "baz": "18446744073709551615", + "qux": "-9223372036854775808" +} diff --git a/betterproto/tests/inputs/fixed/fixed.proto b/betterproto/tests/inputs/fixed/fixed.proto new file mode 100644 index 0000000..50dad84 --- /dev/null +++ b/betterproto/tests/inputs/fixed/fixed.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; + +message Test { + fixed32 foo = 1; + sfixed32 bar = 2; + fixed64 baz = 3; + sfixed64 qux = 4; +}