nelfin / pylint-protobuf

A plugin for making Pylint aware of the fields of protobuf-generated classes
MIT License
29 stars 12 forks source link

False-positive protobuf-type-error on float fields: should accept int/long as well #41

Closed nelfin closed 3 years ago

nelfin commented 3 years ago

Ref #40. Given:

// example.proto
syntax = "proto3";
message Example {
  int32 value = 1;
  float fraction = 2;
}
# issue40b.py
from example_pb2 import Example
Example(fraction=123)

We warn but shouldn't:

$ pylint issue40b.py
************* Module issue40b
issue40b.py:2:0: E5903: Field "Example.fraction" is of type 'float' and value 123 will raise TypeError at runtime (protobuf-type-error)
$ python issue40b.py  # no error