protocolbuffers / protocolbuffers/protobuf

[Python] Protobuf python generated pb2 files are without typing files

Open
#16,115 18 comments 8 reactions 1 assignee View on GitHub

@anandolee is already working on this.

Since Jul 9, 2024.

enhancement keep open python
Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

Description

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:

'google.protobuf.timestamp_pb2' has no 'Timestamp' member .
image

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?

import "google/protobuf/timestamp.proto";

message SomeMessage {
  google.protobuf.Timestamp timestamp = 2;
}

python -m grpc_tools.protoc -I. --python_out=. --pyi_out=. --grpc_python_out=. *.proto

What did you expect to see
Protobuf should include pyi files and pass pylint validation when using timestampa type.

What did you see instead?

'google.protobuf.timestamp_pb2' has no 'Timestamp' member .

Anything else we should know about your project / environment
/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.