Open matejsp opened 6 months ago
This should be fairly easy to do using https://pypi.org/project/mypy-protobuf/ Here's how typeshed currently does it: https://github.com/python/typeshed/blob/main/scripts/generate_proto_stubs.sh
I'd love to see protobuf provide their own generated stubs. In the mean time you can install https://pypi.org/project/types-protobuf/
@Avasam yes for mypy it works with mypy-protobuf, but not with pylint. We actually use both.
Sounds like a pylint issue https://github.com/pylint-dev/pylint/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+pyi+in%3Atitle Pylint didn't even support linting pyi files until last year: https://github.com/pylint-dev/astroid/pull/2182
Specifically relevant issues: https://github.com/pylint-dev/pylint/issues/6281 & https://github.com/pylint-dev/pylint/issues/9185
@Avasam pylint supports pyi just fine and we are using them in our own proto files. But when using timestamp from protobuf package it does not work for that specific type. This is the main reason for this ticket. To also generate typing pyi files. Because then it works out of the box with latest pylint.
For mypy yes it works with mypy-protobuf, but wouldn't it be better to just use python native typing option instead since it is already implemented and it works just bundled generated code is lacking them?
Please generate with pyi files for python for builtin types.
Currently we have a lot of errors using those types with pylint and need to ignore checking:
What version of protobuf and what language are you using? Version: 4.25.2 (from pypi) Language: Python
What operating system (Linux, Windows, ...) and version? MacOSX, Linux
What runtime / compiler are you using (e.g., python version or gcc version) python 3.11.2
What did you do?
What did you expect to see Protobuf should include pyi files and pass pylint validation when using timestampa type.
What did you see instead?
Anything else we should know about your project / environment /