Skip to content
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

fixed/sfixed types convert to float #14

Closed
acetylen opened this issue Jan 23, 2020 · 0 comments · Fixed by #90
Closed

fixed/sfixed types convert to float #14

acetylen opened this issue Jan 23, 2020 · 0 comments · Fixed by #90
Labels
bug Something isn't working medium Medium effort issue, can fit in a single PR small Low effort issue that can easily be picked up
Projects
Milestone

Comments

@acetylen
Copy link

According to the protobuf language guide, fixednn and sfixednn are integer types. However, when betterproto generates dataclasses it treats them as floats.

$ cat foo.proto
syntax = "proto3";
package foo;

message Foo {
  fixed32 bar = 1;
  sfixed32 baz = 2;
  fixed64 qux = 3;
  sfixed64 quux = 4;
}

$ protoc --python_betterproto_out . foo.proto
Writing foo.py
$ cat foo.py
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: foo.proto
# plugin: python-betterproto
from dataclasses import dataclass

import betterproto


@dataclass
class Foo(betterproto.Message):
    bar: float = betterproto.fixed32_field(1)
    baz: float = betterproto.sfixed32_field(2)
    qux: float = betterproto.fixed64_field(3)
    quux: float = betterproto.sfixed64_field(4)

  • betterproto 1.2.2 (from pypi)
  • protoc 3.6.1
  • python 3.7.3
@danielgtaylor danielgtaylor added the bug Something isn't working label Jan 31, 2020
@boukeversteegh boukeversteegh added this to Backlog in Betterproto May 25, 2020
@boukeversteegh boukeversteegh added medium Medium effort issue, can fit in a single PR small Low effort issue that can easily be picked up labels May 25, 2020
@boukeversteegh boukeversteegh added this to the Better Types milestone May 25, 2020
Betterproto automation moved this from Backlog to Done Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working medium Medium effort issue, can fit in a single PR small Low effort issue that can easily be picked up
Projects
Betterproto
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants