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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylint_protobuf-0.22.1.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylint_protobuf-0.22.1-py2.py3-none-any.whl (13.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pylint_protobuf-0.22.1.tar.gz.

File metadata

  • Download URL: pylint_protobuf-0.22.1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for pylint_protobuf-0.22.1.tar.gz
Algorithm Hash digest
SHA256 7ebe0e99ec7de65e18cd9fcdf3b1994be0b985b3491b376cdc5533575912a89d
MD5 b223395fa8d0843245cbdc0b4756b0fa
BLAKE2b-256 2d32eda581bde65d9a53864050f45136d2bf725e5dad15abbd407f7337717635

See more details on using hashes here.

File details

Details for the file pylint_protobuf-0.22.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pylint_protobuf-0.22.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f5b66235d976abc831e1bd7b55520344a907e02f9f164a37a61584db836ab607
MD5 256b29397d2c995c3dea3a235bb943b6
BLAKE2b-256 20605cce1b46c286bb11be55a8e0fd28f987053d9b54bc43f41a3b5c47dcd952

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.22.1 This release

2 files

0.22.0

2 files

0.21.0

2 files

0.20.2

2 files

0.20.1

2 files

0.20.0

2 files

0.19.0

2 files

0.18.5

2 files

0.18.4

2 files

0.18.3

2 files

0.18.2

2 files

0.18.1

2 files

0.18.0

2 files

0.17.0

2 files

0.16.0

2 files

0.15.0

2 files

0.14.1

2 files

0.14

2 files

0.13

2 files

0.12

2 files

0.11

2 files

0.10

2 files

0.9

2 files

0.8

2 files

0.7

2 files

0.6

2 files

0.5

2 files

0.4

2 files

0.3

2 files

0.2

2 files

0.1

2 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