typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Replace mypy-protobuf with protobuf pyi_out

Open matejsp opened this issue 3 months ago • 3 comments

I noticed that pyi_out is a lot cleaner and more readable that mypy-protobuf. Since pyi generation is part of protobuf it is probably prefered instead of unofficial mypy_protobuf.

And there is also one interesting sideeffect that enums constants are not compatible between themselves exposing couple of bugs in our code.

For example:

enum EnumA {
  A_A = 0;
  A_B = 1;
}

enum EnumB {
  B_A = 0;
  B_B = 1;
}

message Msg {
  EnumA name = 1;
}

mypy is not bothered that name can also be used with B_A and B_B. But it works with pyi_out generated code.

matejsp avatar Sep 20 '25 08:09 matejsp

Related: https://github.com/nipunn1313/mypy-protobuf/issues/628 and https://github.com/nipunn1313/mypy-protobuf/issues/368#issuecomment-1223884445

It would be interesting to do a side-by-side comparison.

Avasam avatar Oct 17 '25 00:10 Avasam

https://github.com/protocolbuffers/protobuf/issues/23670

This is at least one difference.

There are also differences in enum value types that are incompatible across the 2 implementations. So it would be a breaking change.

aidandj avatar Oct 17 '25 00:10 aidandj

There is now a somewhat up to date comparison here

aidandj avatar Nov 30 '25 04:11 aidandj