nelfin / pylint-protobuf

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

objects returned from functions always generate E1101 for message fields #26

Closed sagar-infinitus-ai closed 3 years ago

sagar-infinitus-ai commented 4 years ago

Example: proto:

syntax = "proto3";

package bikes;

message Engine {
    int32 displacement = 2;
}

message Motorcycle {
    string brand = 1;
    string name = 2;
    Engine engine = 3;
}

code:

from motorcycles_pb2 import Motorcycle, Engine

def get_motorcycle() -> Motorcycle:
    return Motorcycle()

def something():
    motorcycle = get_motorcycle()
    engine = m.engine

pylint error:

motorcycles/__main__.py:10:13: E1101: Instance of 'Motorcycle' has no 'engine' member (no-member)
nelfin commented 4 years ago

I suspect that these are not being tracked at all and as such are tripping up pylint's default rules. I'll check it out and see what it is.

On Wed., 3 Jun. 2020, 10:30 Sagar Gokhale, notifications@github.com wrote:

Example: proto:

syntax = "proto3";

package bikes;

message Engine { int32 displacement = 2; }

message Motorcycle { string brand = 1; string name = 2; Engine engine = 3; }

code:

from motorcycles_pb2 import Motorcycle, Engine

def get_motorcycle() -> Motorcycle: return Motorcycle()

def something(): motorcycle = get_motorcycle() engine = m.engine

pylint error:

motorcycles/main.py:10:13: E1101: Instance of 'Motorcycle' has no 'engine' member (no-member)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nelfin/pylint-protobuf/issues/26, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSH3MQ4KFCJIYZJQW3WC3RUWKT5ANCNFSM4NRGHL3A .

nelfin commented 3 years ago

@sagar-infinitus-ai: This specific test case is addressed by the 0.14. Can you check that it satisfies your use case?