Make plugin use betterproto generated classes internally
This means the betterproto plugin no longer needs to depend durectly on protobuf. This requires a small runtime hack to monkey patch some google types to get around the fact that the compiler uses proto2, but betterproto expects proto3. Also: - regenerate google.protobuf package - fix a regex bug in the logic for determining whether to use a google wrapper type. - fix a bug causing comments to get mixed up when multiple proto files generate code into a single python module
This commit is contained in:
@@ -1172,6 +1172,7 @@ from .lib.google.protobuf import ( # noqa
|
||||
BytesValue,
|
||||
DoubleValue,
|
||||
Duration,
|
||||
EnumValue,
|
||||
FloatValue,
|
||||
Int32Value,
|
||||
Int64Value,
|
||||
@@ -1238,14 +1239,17 @@ class _WrappedMessage(Message):
|
||||
|
||||
def _get_wrapper(proto_type: str) -> Type:
|
||||
"""Get the wrapper message class for a wrapped type."""
|
||||
|
||||
# TODO: include ListValue and NullValue?
|
||||
return {
|
||||
TYPE_BOOL: BoolValue,
|
||||
TYPE_INT32: Int32Value,
|
||||
TYPE_UINT32: UInt32Value,
|
||||
TYPE_INT64: Int64Value,
|
||||
TYPE_UINT64: UInt64Value,
|
||||
TYPE_FLOAT: FloatValue,
|
||||
TYPE_DOUBLE: DoubleValue,
|
||||
TYPE_STRING: StringValue,
|
||||
TYPE_BYTES: BytesValue,
|
||||
TYPE_DOUBLE: DoubleValue,
|
||||
TYPE_FLOAT: FloatValue,
|
||||
TYPE_ENUM: EnumValue,
|
||||
TYPE_INT32: Int32Value,
|
||||
TYPE_INT64: Int64Value,
|
||||
TYPE_STRING: StringValue,
|
||||
TYPE_UINT32: UInt32Value,
|
||||
TYPE_UINT64: UInt64Value,
|
||||
}[proto_type]
|
||||
|
Reference in New Issue
Block a user