Skip to main content

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.

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)

Source distribution for pylint-protobuf 0.22.1
File Size Uploaded
pylint_protobuf-0.22.1.tar.gz 30.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylint-protobuf 0.22.1
File Interpreter ABI Platform
pylint_protobuf-0.22.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

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

Release history Release notifications | RSS feed

This release

0.22.1 This release

2 release files

0.22.0

2 release files

0.20.2

2 release files

0.20.1

2 release files

0.19.0

2 release files

0.18.5

2 release files

0.18.4

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.1

2 release files

0.14

2 release files

0.13

2 release files

0.12

2 release files

0.11

2 release files

0.10

2 release files

0.9

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page