Skip to content

Migration from 2.x to 3.x

Upgrade Python to 3.8 or above

Support for Python 3.7 is dropped.

@message decorator

The decorator has been removed. You should inherit your message classes from BaseMessage.

Fields

Replace annotations like foo: int = field(1) with foo: Annotated[int, Field(1)].

Integers

  • Use the built-in int for variable-length integers, which use two's compliment negative representation.
  • For ZigZag-encoded integers the new annotation ZigZagInt is introduced.

Well-known types

typing.Any, datetime.datetime, and datetime.timedelta are no longer mapped into the .proto types. Use pure_protobuf.well_known.Any_, pure_protobuf.well_known.Timestamp, and pure_protobuf.well_known.Duration explicitly.

Anyof

Replace any_of parameters with AnyOf descriptors.