pylint-protobuf
pylint-protobuf is a Pylint plugin for making Pylint aware of generated
fields from Protobuf types.
Install
Install from PyPI via:
pip install pylint-protobuf
Add or update pylintrc to load pylint-protobuf:
[MASTER]
load-plugins=pylint_protobuf
Example
$ cat <<EOF >person.proto
message Person {
required string name = 1;
}
EOF
$ protoc person.proto --python_out=.
$ cat <<EOF >readme.py
from person_pb2 import Person
p = Person('all arguments must be kwargs')
p.invalid_field = 'value'
p.name = 123
EOF
$ pip install pylint-protobuf
$ pylint --load-plugins=pylint_protobuf readme.py
************* Module readme
readme.py:2:4: E5904: Positional arguments are not allowed in message constructors and will raise TypeError (protobuf-no-posargs)
readme.py:3:0: E5901: Field 'invalid_field' does not appear in the declared fields of protobuf-generated class 'Person' and will raise AttributeError on access (protobuf-undefined-attribute)
readme.py:4:0: E5903: Field "Person.name" is of type 'str' and value 123 will raise TypeError at runtime (protobuf-type-error)
Supported Python Versions
pylint-protobuf supports Python 3.8 at a minimum.
Known Issues
pylint-protobuf does not currently support the following concepts:
- Some features of extensions: non-nested extensions, HasExtension(), ClearExtension(), type checking
Alternatives
mypy-protobuf
A protoc compiler plugin for generating .pyi stubs from .proto files.
Fully-featured and well supported, a useful extension to a mypy workflow.
May be better suited to your usecase if you control the entire pipeline. May
not be suited if you are a downstream consumer of generated _pb2.py modules
with no access to the original .proto definitions, in which case
pylint-protobuf may be better suited for your use.
Metadata
Release files for pylint-protobuf 0.22.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylint_protobuf-0.22.1.tar.gz | 30.2 kB | Without provenance | Details for pylint_protobuf-0.22.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylint_protobuf-0.22.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pylint_protobuf-0.22.1-py2.py3-none-any.whl |
Total release size: 44.0 kB
Release files / pylint_protobuf-0.22.1.tar.gz
| Download URL | pylint_protobuf-0.22.1.tar.gz |
|---|---|
| Size | 30.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ebe0e99ec7de65e18cd9fcdf3b1994be0b985b3491b376cdc5533575912a89d
|
|
BLAKE2b-256 checksum How to use checksums |
2d32eda581bde65d9a53864050f45136d2bf725e5dad15abbd407f7337717635
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Release files / pylint_protobuf-0.22.1-py2.py3-none-any.whl
| Download URL | pylint_protobuf-0.22.1-py2.py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f5b66235d976abc831e1bd7b55520344a907e02f9f164a37a61584db836ab607
|
|
BLAKE2b-256 checksum How to use checksums |
20605cce1b46c286bb11be55a8e0fd28f987053d9b54bc43f41a3b5c47dcd952
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Security for pylint-protobuf 0.22.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.