pylint-protobuf

raw JSON →
0.22.0 verified Fri May 01 auth: no python maintenance

A Pylint plugin that makes Pylint aware of the fields of protobuf-generated classes, preventing false positives like 'no-member' when accessing protobuf message attributes. Current version: 0.22.0. Released periodically, with the last release in 2021.

pip install pylint-protobuf
error pylint: 'pylint-protobuf' is not a valid plugin
cause Using hyphen instead of underscore in the plugin name (old style).
fix
Replace 'pylint-protobuf' with 'pylint_protobuf' in your Pylint configuration.
error Module 'mymodule' has no 'some_field' member (no-member)
cause The plugin is either not loaded or cannot access the protobuf descriptor.
fix
1) Ensure --load-plugins=pylint_protobuf is set. 2) Verify that protobuf descriptors are present (compile with --descriptor_set_out).
gotcha The plugin only works if the protobuf descriptor files are generated *with* the --descriptor_set_out flag and accessible at runtime. Without descriptors, fields are not recognized.
fix Ensure that your protobuf compilation includes --descriptor_set_out and that the generated descriptor files are deployed alongside the code.
deprecated The import path has changed from 'pylint-protobuf' (hyphen) to 'pylint_protobuf' (underscore). Loading the old name will fail with a module-not-found error.
fix Use 'pylint_protobuf' in your Pylint config or command line.
breaking Version 0.21.0 dropped support for Python 2 and older Pylint versions (<2.4).
fix Upgrade to Python 3.6+ and Pylint 2.4+.

Load the plugin via Pylint's --load-plugins flag or config file to eliminate false positives on protobuf fields.

# Write a .pylintrc or pyproject.toml with:
# [MASTER]
# load-plugins=pylint_protobuf
#
# Then run pylint on your project.
# Example of usage without config file:
import os
os.system('pylint --load-plugins=pylint_protobuf my_module.py')