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.
Raw data
{
"_id": null,
"home_page": "https://github.com/nelfin/pylint-protobuf",
"name": "pylint-protobuf",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pylint,plugin,protobuf",
"author": "Andrew Haigh",
"author_email": "hello@nelf.in",
"download_url": "https://files.pythonhosted.org/packages/9f/11/c01c1e5cc589f344baa8adfa0e14afad938c2325ec096133b72c18baccc1/pylint-protobuf-0.22.0.tar.gz",
"platform": null,
"description": "pylint-protobuf\n===============\n\n`pylint-protobuf` is a Pylint plugin for making Pylint aware of generated\nfields from Protobuf types.\n\n## Install\n\nInstall from PyPI via:\n\n pip install pylint-protobuf\n\nAdd or update `pylintrc` to load `pylint-protobuf`:\n\n [MASTER]\n load-plugins=pylint_protobuf\n\n## Example\n\n $ cat <<EOF >person.proto\n message Person {\n required string name = 1;\n }\n EOF\n $ protoc person.proto --python_out=.\n $ cat <<EOF >readme.py\n from person_pb2 import Person\n p = Person('all arguments must be kwargs')\n p.invalid_field = 'value'\n p.name = 123\n EOF\n $ pip install pylint-protobuf\n $ pylint --load-plugins=pylint_protobuf readme.py\n ************* Module readme\n readme.py:2:4: E5904: Positional arguments are not allowed in message constructors and will raise TypeError (protobuf-no-posargs)\n 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)\n readme.py:4:0: E5903: Field \"Person.name\" is of type 'str' and value 123 will raise TypeError at runtime (protobuf-type-error)\n\n## Supported Python Versions\n\n`pylint-protobuf` supports Python 3.8 at a minimum.\n\n## Known Issues\n\n`pylint-protobuf` does not currently support the following concepts:\n\n* Some features of extensions: non-nested extensions, HasExtension(),\n ClearExtension(), type checking\n\n## Alternatives\n\n### mypy-protobuf\n\nA `protoc` compiler plugin for generating `.pyi` stubs from `.proto` files.\nFully-featured and well supported, a useful extension to a `mypy` workflow.\nMay be better suited to your usecase if you control the entire pipeline. May\n_not_ be suited if you are a downstream consumer of generated `_pb2.py` modules\nwith no access to the original `.proto` definitions, in which case\n`pylint-protobuf` may be better suited for your use.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A plugin for making Pylint aware of the fields of protobuf-generated classes",
"version": "0.22.0",
"project_urls": {
"Homepage": "https://github.com/nelfin/pylint-protobuf"
},
"split_keywords": [
"pylint",
"plugin",
"protobuf"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "904fbc89becc629fa5b4b05199bc1e599d58d81f5ea0d5e707bfe84963221b50",
"md5": "8c0b205f13ed96578c2939ec71ae02e8",
"sha256": "d6c5823ca55fb0141b862569aff18e9abc287409a105a9061c1327d425999f09"
},
"downloads": -1,
"filename": "pylint_protobuf-0.22.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8c0b205f13ed96578c2939ec71ae02e8",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 44280,
"upload_time": "2023-12-10T01:38:47",
"upload_time_iso_8601": "2023-12-10T01:38:47.079378Z",
"url": "https://files.pythonhosted.org/packages/90/4f/bc89becc629fa5b4b05199bc1e599d58d81f5ea0d5e707bfe84963221b50/pylint_protobuf-0.22.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9f11c01c1e5cc589f344baa8adfa0e14afad938c2325ec096133b72c18baccc1",
"md5": "49ffbb6440b2e36630ac5a483d456946",
"sha256": "fd569200698cf30cb85f13cc5cfff40c49285599bc972b455e932c1805216a11"
},
"downloads": -1,
"filename": "pylint-protobuf-0.22.0.tar.gz",
"has_sig": false,
"md5_digest": "49ffbb6440b2e36630ac5a483d456946",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 31589,
"upload_time": "2023-12-10T01:38:49",
"upload_time_iso_8601": "2023-12-10T01:38:49.258892Z",
"url": "https://files.pythonhosted.org/packages/9f/11/c01c1e5cc589f344baa8adfa0e14afad938c2325ec096133b72c18baccc1/pylint-protobuf-0.22.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-10 01:38:49",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nelfin",
"github_project": "pylint-protobuf",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "pylint-protobuf"
}