Closed dsandbrink closed 3 years ago
Hi @dsandbrink, thanks for the report. Yeah, as it currently stands, pylint-protobuf
does rely on implementation details of google.protobuf
. I'll see if the pure-Python definitions work for all cases, but I don't have access to a Windows environment at the moment so I'll need a hand testing that.
Give that fix a try with pip install git+https://github.com/nelfin/pylint-protobuf@8273133719b86731f28f3c0879d7739377affc92
Hi @nelfin , thanks for the quick fix! I tested it on Windows with both Python 3.7 and Python 3.8 and on Ubuntu 20.04 with Python 3.8 successfully.
Note that when using Python 3.8 on Windows (we just switched our code base to Python 3.8) I get some strange false positive warnings like
E5903: Field "Project.create_time" is of type 'Timestamp' and value 'Timestamp()' will raise TypeError at runtime (protobuf-type-error)
I am pretty sure that this is unrelated to your fix, because these warnings do not show when using Linux or Python 3.7. I'll try to create a minimal example to check if I can reproduce this and will create a separate issue (if I should find one ;) ).
for me I downgraded protobuf
pip install protobuf==3.19.6
Hi,
currently the protobuf Python package does not contain the C++ extension when installing on Windows for Python 3.8+, see ImportError: cannot import name '_message' from 'google.protobuf.pyext' on windows and python3.8 #7765.
This causes an AttributeError when trying to run pylint with the pylint-protobuf plugin installed:
The root cause is at the top of transport.py, where some types are imported from the extention:
I think this should fall back to the pure Python definition of those classes if the
_message
module is unavailable for any reason: