From 45f11582495c71c5861cecde9207fdd03da5ad97 Mon Sep 17 00:00:00 2001 From: Adrien Vannson Date: Fri, 20 Dec 2024 16:51:59 +0100 Subject: [PATCH] Use published betterproto version --- poetry.lock | 96 ++-- pyproject.toml | 2 +- .../lib/std/google/protobuf/__init__.py | 522 +++++++++--------- .../std/google/protobuf/compiler/__init__.py | 50 +- src/betterproto2_compiler/plugin/models.py | 6 +- .../templates/header.py.j2 | 8 +- .../templates/template.py.j2 | 6 +- 7 files changed, 345 insertions(+), 345 deletions(-) diff --git a/poetry.lock b/poetry.lock index dbe9d715..42252b68 100644 --- a/poetry.lock +++ b/poetry.lock @@ -44,29 +44,25 @@ files = [ dev = ["freezegun (>=1.0,<2.0)", "pytest (>=6.0)", "pytest-cov"] [[package]] -name = "betterproto" -version = "2.0.0b7" +name = "betterproto2" +version = "0.0.2" description = "A better Protobuf / gRPC generator & library" optional = false -python-versions = "^3.8" -files = [] -develop = false +python-versions = "<4.0,>=3.8" +files = [ + {file = "betterproto2-0.0.2-py3-none-any.whl", hash = "sha256:540d87a9ee30f12852827f9dc69483da7aeb9d17f46864c3b391f7f7fdb5ec07"}, + {file = "betterproto2-0.0.2.tar.gz", hash = "sha256:f55b9069256e199d61b49230516baf850fe928256e57e2b4d3b9034162d72e14"}, +] [package.dependencies] -grpclib = "^0.4.1" -python-dateutil = "^2.8" -typing-extensions = "^4.7.1" +grpclib = ">=0.4.1,<0.5.0" +python-dateutil = ">=2.8,<3.0" +typing-extensions = ">=4.7.1,<5.0.0" [package.extras] compiler = ["jinja2 (>=3.0.3)", "ruff (>=0.7.4,<0.8.0)"] rust-codec = ["betterproto-rust-codec (==0.1.1)"] -[package.source] -type = "git" -url = "https://github.com/betterproto/python-betterproto2" -reference = "881bd6e09a809dc61add4ae4ed6a3c70c1fca00a" -resolved_reference = "881bd6e09a809dc61add4ae4ed6a3c70c1fca00a" - [[package]] name = "certifi" version = "2024.12.14" @@ -872,49 +868,49 @@ typing-extensions = {version = ">=4.1.0", markers = "python_version < \"3.11\""} [[package]] name = "mypy" -version = "1.13.0" +version = "1.14.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ - {file = "mypy-1.13.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6607e0f1dd1fb7f0aca14d936d13fd19eba5e17e1cd2a14f808fa5f8f6d8f60a"}, - {file = "mypy-1.13.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8a21be69bd26fa81b1f80a61ee7ab05b076c674d9b18fb56239d72e21d9f4c80"}, - {file = "mypy-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b2353a44d2179846a096e25691d54d59904559f4232519d420d64da6828a3a7"}, - {file = "mypy-1.13.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0730d1c6a2739d4511dc4253f8274cdd140c55c32dfb0a4cf8b7a43f40abfa6f"}, - {file = "mypy-1.13.0-cp310-cp310-win_amd64.whl", hash = "sha256:c5fc54dbb712ff5e5a0fca797e6e0aa25726c7e72c6a5850cfd2adbc1eb0a372"}, - {file = "mypy-1.13.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:581665e6f3a8a9078f28d5502f4c334c0c8d802ef55ea0e7276a6e409bc0d82d"}, - {file = "mypy-1.13.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3ddb5b9bf82e05cc9a627e84707b528e5c7caaa1c55c69e175abb15a761cec2d"}, - {file = "mypy-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:20c7ee0bc0d5a9595c46f38beb04201f2620065a93755704e141fcac9f59db2b"}, - {file = "mypy-1.13.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3790ded76f0b34bc9c8ba4def8f919dd6a46db0f5a6610fb994fe8efdd447f73"}, - {file = "mypy-1.13.0-cp311-cp311-win_amd64.whl", hash = "sha256:51f869f4b6b538229c1d1bcc1dd7d119817206e2bc54e8e374b3dfa202defcca"}, - {file = "mypy-1.13.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:5c7051a3461ae84dfb5dd15eff5094640c61c5f22257c8b766794e6dd85e72d5"}, - {file = "mypy-1.13.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:39bb21c69a5d6342f4ce526e4584bc5c197fd20a60d14a8624d8743fffb9472e"}, - {file = "mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:164f28cb9d6367439031f4c81e84d3ccaa1e19232d9d05d37cb0bd880d3f93c2"}, - {file = "mypy-1.13.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a4c1bfcdbce96ff5d96fc9b08e3831acb30dc44ab02671eca5953eadad07d6d0"}, - {file = "mypy-1.13.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0affb3a79a256b4183ba09811e3577c5163ed06685e4d4b46429a271ba174d2"}, - {file = "mypy-1.13.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a7b44178c9760ce1a43f544e595d35ed61ac2c3de306599fa59b38a6048e1aa7"}, - {file = "mypy-1.13.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5d5092efb8516d08440e36626f0153b5006d4088c1d663d88bf79625af3d1d62"}, - {file = "mypy-1.13.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:de2904956dac40ced10931ac967ae63c5089bd498542194b436eb097a9f77bc8"}, - {file = "mypy-1.13.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7bfd8836970d33c2105562650656b6846149374dc8ed77d98424b40b09340ba7"}, - {file = "mypy-1.13.0-cp313-cp313-win_amd64.whl", hash = "sha256:9f73dba9ec77acb86457a8fc04b5239822df0c14a082564737833d2963677dbc"}, - {file = "mypy-1.13.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:100fac22ce82925f676a734af0db922ecfea991e1d7ec0ceb1e115ebe501301a"}, - {file = "mypy-1.13.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7bcb0bb7f42a978bb323a7c88f1081d1b5dee77ca86f4100735a6f541299d8fb"}, - {file = "mypy-1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bde31fc887c213e223bbfc34328070996061b0833b0a4cfec53745ed61f3519b"}, - {file = "mypy-1.13.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:07de989f89786f62b937851295ed62e51774722e5444a27cecca993fc3f9cd74"}, - {file = "mypy-1.13.0-cp38-cp38-win_amd64.whl", hash = "sha256:4bde84334fbe19bad704b3f5b78c4abd35ff1026f8ba72b29de70dda0916beb6"}, - {file = "mypy-1.13.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0246bcb1b5de7f08f2826451abd947bf656945209b140d16ed317f65a17dc7dc"}, - {file = "mypy-1.13.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7f5b7deae912cf8b77e990b9280f170381fdfbddf61b4ef80927edd813163732"}, - {file = "mypy-1.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7029881ec6ffb8bc233a4fa364736789582c738217b133f1b55967115288a2bc"}, - {file = "mypy-1.13.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3e38b980e5681f28f033f3be86b099a247b13c491f14bb8b1e1e134d23bb599d"}, - {file = "mypy-1.13.0-cp39-cp39-win_amd64.whl", hash = "sha256:a6789be98a2017c912ae6ccb77ea553bbaf13d27605d2ca20a76dfbced631b24"}, - {file = "mypy-1.13.0-py3-none-any.whl", hash = "sha256:9c250883f9fd81d212e0952c92dbfcc96fc237f4b7c92f56ac81fd48460b3e5a"}, - {file = "mypy-1.13.0.tar.gz", hash = "sha256:0291a61b6fbf3e6673e3405cfcc0e7650bebc7939659fdca2702958038bd835e"}, + {file = "mypy-1.14.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e971c1c667007f9f2b397ffa80fa8e1e0adccff336e5e77e74cb5f22868bee87"}, + {file = "mypy-1.14.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e86aaeaa3221a278c66d3d673b297232947d873773d61ca3ee0e28b2ff027179"}, + {file = "mypy-1.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1628c5c3ce823d296e41e2984ff88c5861499041cb416a8809615d0c1f41740e"}, + {file = "mypy-1.14.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:7fadb29b77fc14a0dd81304ed73c828c3e5cde0016c7e668a86a3e0dfc9f3af3"}, + {file = "mypy-1.14.0-cp310-cp310-win_amd64.whl", hash = "sha256:3fa76988dc760da377c1e5069200a50d9eaaccf34f4ea18428a3337034ab5a44"}, + {file = "mypy-1.14.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6e73c8a154eed31db3445fe28f63ad2d97b674b911c00191416cf7f6459fd49a"}, + {file = "mypy-1.14.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:273e70fcb2e38c5405a188425aa60b984ffdcef65d6c746ea5813024b68c73dc"}, + {file = "mypy-1.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1daca283d732943731a6a9f20fdbcaa927f160bc51602b1d4ef880a6fb252015"}, + {file = "mypy-1.14.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:7e68047bedb04c1c25bba9901ea46ff60d5eaac2d71b1f2161f33107e2b368eb"}, + {file = "mypy-1.14.0-cp311-cp311-win_amd64.whl", hash = "sha256:7a52f26b9c9b1664a60d87675f3bae00b5c7f2806e0c2800545a32c325920bcc"}, + {file = "mypy-1.14.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d5326ab70a6db8e856d59ad4cb72741124950cbbf32e7b70e30166ba7bbf61dd"}, + {file = "mypy-1.14.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bf4ec4980bec1e0e24e5075f449d014011527ae0055884c7e3abc6a99cd2c7f1"}, + {file = "mypy-1.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:390dfb898239c25289495500f12fa73aa7f24a4c6d90ccdc165762462b998d63"}, + {file = "mypy-1.14.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7e026d55ddcd76e29e87865c08cbe2d0104e2b3153a523c529de584759379d3d"}, + {file = "mypy-1.14.0-cp312-cp312-win_amd64.whl", hash = "sha256:585ed36031d0b3ee362e5107ef449a8b5dfd4e9c90ccbe36414ee405ee6b32ba"}, + {file = "mypy-1.14.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e9f6f4c0b27401d14c483c622bc5105eff3911634d576bbdf6695b9a7c1ba741"}, + {file = "mypy-1.14.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:56b2280cedcb312c7a79f5001ae5325582d0d339bce684e4a529069d0e7ca1e7"}, + {file = "mypy-1.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:342de51c48bab326bfc77ce056ba08c076d82ce4f5a86621f972ed39970f94d8"}, + {file = "mypy-1.14.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:00df23b42e533e02a6f0055e54de9a6ed491cd8b7ea738647364fd3a39ea7efc"}, + {file = "mypy-1.14.0-cp313-cp313-win_amd64.whl", hash = "sha256:e8c8387e5d9dff80e7daf961df357c80e694e942d9755f3ad77d69b0957b8e3f"}, + {file = "mypy-1.14.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b16738b1d80ec4334654e89e798eb705ac0c36c8a5c4798496cd3623aa02286"}, + {file = "mypy-1.14.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:10065fcebb7c66df04b05fc799a854b1ae24d9963c8bb27e9064a9bdb43aa8ad"}, + {file = "mypy-1.14.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fbb7d683fa6bdecaa106e8368aa973ecc0ddb79a9eaeb4b821591ecd07e9e03c"}, + {file = "mypy-1.14.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:3498cb55448dc5533e438cd13d6ddd28654559c8c4d1fd4b5ca57a31b81bac01"}, + {file = "mypy-1.14.0-cp38-cp38-win_amd64.whl", hash = "sha256:c7b243408ea43755f3a21a0a08e5c5ae30eddb4c58a80f415ca6b118816e60aa"}, + {file = "mypy-1.14.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:14117b9da3305b39860d0aa34b8f1ff74d209a368829a584eb77524389a9c13e"}, + {file = "mypy-1.14.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:af98c5a958f9c37404bd4eef2f920b94874507e146ed6ee559f185b8809c44cc"}, + {file = "mypy-1.14.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f0b343a1d3989547024377c2ba0dca9c74a2428ad6ed24283c213af8dbb0710b"}, + {file = "mypy-1.14.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:cdb5563c1726c85fb201be383168f8c866032db95e1095600806625b3a648cb7"}, + {file = "mypy-1.14.0-cp39-cp39-win_amd64.whl", hash = "sha256:74e925649c1ee0a79aa7448baf2668d81cc287dc5782cff6a04ee93f40fb8d3f"}, + {file = "mypy-1.14.0-py3-none-any.whl", hash = "sha256:2238d7f93fc4027ed1efc944507683df3ba406445a2b6c96e79666a045aadfab"}, + {file = "mypy-1.14.0.tar.gz", hash = "sha256:822dbd184d4a9804df5a7d5335a68cf7662930e70b8c1bc976645d1509f9a9d6"}, ] [package.dependencies] -mypy-extensions = ">=1.0.0" +mypy_extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=4.6.0" +typing_extensions = ">=4.6.0" [package.extras] dmypy = ["psutil (>=4.0)"] @@ -1565,4 +1561,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "19b0cea065178354a26f640b1281d53981767f8e120f09a4c0f1a77b4fb16127" +content-hash = "14f7a0419039f53a2db6c2b86bde16273912439556d9b5fa52ac51fe03121eea" diff --git a/pyproject.toml b/pyproject.toml index f14e9b17..ac849b57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ packages = [ [tool.poetry.dependencies] python = "^3.10" -betterproto = { git = "https://github.com/betterproto/python-betterproto2", rev = "881bd6e09a809dc61add4ae4ed6a3c70c1fca00a" } +betterproto2 = "0.0.2" # The Ruff version is pinned. To update it, also update it in .pre-commit-config.yaml ruff = "~0.7.4" grpclib = "^0.4.1" diff --git a/src/betterproto2_compiler/lib/std/google/protobuf/__init__.py b/src/betterproto2_compiler/lib/std/google/protobuf/__init__.py index 6f1a65db..dc118b7f 100644 --- a/src/betterproto2_compiler/lib/std/google/protobuf/__init__.py +++ b/src/betterproto2_compiler/lib/std/google/protobuf/__init__.py @@ -3,7 +3,7 @@ # google/protobuf/duration.proto, google/protobuf/empty.proto, google/protobuf/field_mask.proto, # google/protobuf/source_context.proto, google/protobuf/struct.proto, google/protobuf/timestamp.proto, # google/protobuf/type.proto, google/protobuf/wrappers.proto -# plugin: python-betterproto +# plugin: python-betterproto2 # This file has been @generated __all__ = ( @@ -81,12 +81,12 @@ Optional, ) -import betterproto -from betterproto.utils import hybridmethod +import betterproto2 +from betterproto2.utils import hybridmethod from typing_extensions import Self -class Syntax(betterproto.Enum): +class Syntax(betterproto2.Enum): """The syntax in which a protocol buffer element is defined.""" PROTO2 = 0 @@ -96,7 +96,7 @@ class Syntax(betterproto.Enum): """Syntax `proto3`.""" -class FieldKind(betterproto.Enum): +class FieldKind(betterproto2.Enum): """Basic field types.""" TYPE_UNKNOWN = 0 @@ -157,7 +157,7 @@ class FieldKind(betterproto.Enum): """Field type sint64.""" -class FieldCardinality(betterproto.Enum): +class FieldCardinality(betterproto2.Enum): """Whether a field is optional, required, or repeated.""" CARDINALITY_UNKNOWN = 0 @@ -173,7 +173,7 @@ class FieldCardinality(betterproto.Enum): """For repeated fields.""" -class FieldDescriptorProtoType(betterproto.Enum): +class FieldDescriptorProtoType(betterproto2.Enum): """ """ TYPE_DOUBLE = 1 @@ -265,7 +265,7 @@ class FieldDescriptorProtoType(betterproto.Enum): """Uses ZigZag encoding.""" -class FieldDescriptorProtoLabel(betterproto.Enum): +class FieldDescriptorProtoLabel(betterproto2.Enum): """ """ LABEL_OPTIONAL = 1 @@ -282,7 +282,7 @@ class FieldDescriptorProtoLabel(betterproto.Enum): """ -class FileOptionsOptimizeMode(betterproto.Enum): +class FileOptionsOptimizeMode(betterproto2.Enum): """Generated classes can be optimized for speed or code size.""" SPEED = 1 @@ -299,7 +299,7 @@ class FileOptionsOptimizeMode(betterproto.Enum): """Generate code using MessageLite and the lite runtime.""" -class FieldOptionsCType(betterproto.Enum): +class FieldOptionsCType(betterproto2.Enum): """ """ STRING = 0 @@ -316,7 +316,7 @@ class FieldOptionsCType(betterproto.Enum): """ -class FieldOptionsJsType(betterproto.Enum): +class FieldOptionsJsType(betterproto2.Enum): """ """ JS_NORMAL = 0 @@ -329,7 +329,7 @@ class FieldOptionsJsType(betterproto.Enum): """Use JavaScript numbers.""" -class MethodOptionsIdempotencyLevel(betterproto.Enum): +class MethodOptionsIdempotencyLevel(betterproto2.Enum): """ Is this method side-effect-free (or safe in HTTP parlance), or idempotent, or neither? HTTP based RPC implementation may choose GET verb for safe @@ -348,7 +348,7 @@ class MethodOptionsIdempotencyLevel(betterproto.Enum): """idempotent, but may have side effects""" -class NullValue(betterproto.Enum): +class NullValue(betterproto2.Enum): """ `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. @@ -361,7 +361,7 @@ class NullValue(betterproto.Enum): @dataclass(eq=False, repr=False) -class Any(betterproto.Message): +class Any(betterproto2.Message): """ `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. @@ -443,7 +443,7 @@ class Any(betterproto.Message): } """ - type_url: str = betterproto.string_field(1) + type_url: str = betterproto2.string_field(1) """ A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least @@ -474,20 +474,20 @@ class Any(betterproto.Message): used with implementation specific semantics. """ - value: bytes = betterproto.bytes_field(2) + value: bytes = betterproto2.bytes_field(2) """ Must be a valid serialized protocol buffer of the above specified type. """ @dataclass(eq=False, repr=False) -class SourceContext(betterproto.Message): +class SourceContext(betterproto2.Message): """ `SourceContext` represents information about the source of a protobuf element, like the file in which it is defined. """ - file_name: str = betterproto.string_field(1) + file_name: str = betterproto2.string_field(1) """ The path-qualified name of the .proto file that contained the associated protobuf element. For example: `"google/protobuf/source_context.proto"`. @@ -495,115 +495,115 @@ class SourceContext(betterproto.Message): @dataclass(eq=False, repr=False) -class Type(betterproto.Message): +class Type(betterproto2.Message): """A protocol buffer message type.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """The fully qualified message name.""" - fields: List["Field"] = betterproto.message_field(2, repeated=True) + fields: List["Field"] = betterproto2.message_field(2, repeated=True) """The list of fields.""" - oneofs: List[str] = betterproto.string_field(3, repeated=True) + oneofs: List[str] = betterproto2.string_field(3, repeated=True) """The list of types appearing in `oneof` definitions in this type.""" - options: List["Option"] = betterproto.message_field(4, repeated=True) + options: List["Option"] = betterproto2.message_field(4, repeated=True) """The protocol buffer options.""" - source_context: "SourceContext" = betterproto.message_field(5) + source_context: "SourceContext" = betterproto2.message_field(5) """The source context.""" - syntax: "Syntax" = betterproto.enum_field(6, enum_default_value=lambda: Syntax.try_value(0)) + syntax: "Syntax" = betterproto2.enum_field(6, enum_default_value=lambda: Syntax.try_value(0)) """The source syntax.""" @dataclass(eq=False, repr=False) -class Field(betterproto.Message): +class Field(betterproto2.Message): """A single field of a message type.""" - kind: "FieldKind" = betterproto.enum_field(1, enum_default_value=lambda: FieldKind.try_value(0)) + kind: "FieldKind" = betterproto2.enum_field(1, enum_default_value=lambda: FieldKind.try_value(0)) """The field type.""" - cardinality: "FieldCardinality" = betterproto.enum_field( + cardinality: "FieldCardinality" = betterproto2.enum_field( 2, enum_default_value=lambda: FieldCardinality.try_value(0) ) """The field cardinality.""" - number: int = betterproto.int32_field(3) + number: int = betterproto2.int32_field(3) """The field number.""" - name: str = betterproto.string_field(4) + name: str = betterproto2.string_field(4) """The field name.""" - type_url: str = betterproto.string_field(6) + type_url: str = betterproto2.string_field(6) """ The field type URL, without the scheme, for message or enumeration types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. """ - oneof_index: int = betterproto.int32_field(7) + oneof_index: int = betterproto2.int32_field(7) """ The index of the field type in `Type.oneofs`, for message or enumeration types. The first type has index 1; zero means the type is not in the list. """ - packed: bool = betterproto.bool_field(8) + packed: bool = betterproto2.bool_field(8) """Whether to use alternative packed wire representation.""" - options: List["Option"] = betterproto.message_field(9, repeated=True) + options: List["Option"] = betterproto2.message_field(9, repeated=True) """The protocol buffer options.""" - json_name: str = betterproto.string_field(10) + json_name: str = betterproto2.string_field(10) """The field JSON name.""" - default_value: str = betterproto.string_field(11) + default_value: str = betterproto2.string_field(11) """ The string value of the default value of this field. Proto2 syntax only. """ @dataclass(eq=False, repr=False) -class Enum(betterproto.Message): +class Enum(betterproto2.Message): """Enum type definition.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """Enum type name.""" - enumvalue: List["EnumValue"] = betterproto.message_field(2, wraps=betterproto.TYPE_ENUM, repeated=True) + enumvalue: List["EnumValue"] = betterproto2.message_field(2, wraps=betterproto2.TYPE_ENUM, repeated=True) """Enum value definitions.""" - options: List["Option"] = betterproto.message_field(3, repeated=True) + options: List["Option"] = betterproto2.message_field(3, repeated=True) """Protocol buffer options.""" - source_context: "SourceContext" = betterproto.message_field(4) + source_context: "SourceContext" = betterproto2.message_field(4) """The source context.""" - syntax: "Syntax" = betterproto.enum_field(5, enum_default_value=lambda: Syntax.try_value(0)) + syntax: "Syntax" = betterproto2.enum_field(5, enum_default_value=lambda: Syntax.try_value(0)) """The source syntax.""" @dataclass(eq=False, repr=False) -class EnumValue(betterproto.Message): +class EnumValue(betterproto2.Message): """Enum value definition.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """Enum value name.""" - number: int = betterproto.int32_field(2) + number: int = betterproto2.int32_field(2) """Enum value number.""" - options: List["Option"] = betterproto.message_field(3, repeated=True) + options: List["Option"] = betterproto2.message_field(3, repeated=True) """Protocol buffer options.""" @dataclass(eq=False, repr=False) -class Option(betterproto.Message): +class Option(betterproto2.Message): """ A protocol buffer option, which can be attached to a message, field, enumeration, etc. """ - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ The option's name. For protobuf built-in options (options defined in descriptor.proto), this is the short name. For example, `"map_entry"`. @@ -611,7 +611,7 @@ class Option(betterproto.Message): `"google.api.http"`. """ - value: "Any" = betterproto.message_field(2) + value: "Any" = betterproto2.message_field(2) """ The option's value packed in an Any message. If the value is a primitive, the corresponding wrapper type defined in google/protobuf/wrappers.proto @@ -621,7 +621,7 @@ class Option(betterproto.Message): @dataclass(eq=False, repr=False) -class Api(betterproto.Message): +class Api(betterproto2.Message): """ Api is a light-weight descriptor for an API Interface. @@ -634,19 +634,19 @@ class Api(betterproto.Message): detailed terminology. """ - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ The fully qualified name of this interface, including package name followed by the interface's simple name. """ - methods: List["Method"] = betterproto.message_field(2, repeated=True) + methods: List["Method"] = betterproto2.message_field(2, repeated=True) """The methods of this interface, in unspecified order.""" - options: List["Option"] = betterproto.message_field(3, repeated=True) + options: List["Option"] = betterproto2.message_field(3, repeated=True) """Any metadata attached to the interface.""" - version: str = betterproto.string_field(4) + version: str = betterproto2.string_field(4) """ A version string for this interface. If specified, must have the form `major-version.minor-version`, as in `1.10`. If the minor version is @@ -669,47 +669,47 @@ class Api(betterproto.Message): experimental, non-GA interfaces. """ - source_context: "SourceContext" = betterproto.message_field(5) + source_context: "SourceContext" = betterproto2.message_field(5) """ Source context for the protocol buffer service represented by this message. """ - mixins: List["Mixin"] = betterproto.message_field(6, repeated=True) + mixins: List["Mixin"] = betterproto2.message_field(6, repeated=True) """Included interfaces. See [Mixin][].""" - syntax: "Syntax" = betterproto.enum_field(7, enum_default_value=lambda: Syntax.try_value(0)) + syntax: "Syntax" = betterproto2.enum_field(7, enum_default_value=lambda: Syntax.try_value(0)) """The source syntax of the service.""" @dataclass(eq=False, repr=False) -class Method(betterproto.Message): +class Method(betterproto2.Message): """Method represents a method of an API interface.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """The simple name of this method.""" - request_type_url: str = betterproto.string_field(2) + request_type_url: str = betterproto2.string_field(2) """A URL of the input message type.""" - request_streaming: bool = betterproto.bool_field(3) + request_streaming: bool = betterproto2.bool_field(3) """If true, the request is streamed.""" - response_type_url: str = betterproto.string_field(4) + response_type_url: str = betterproto2.string_field(4) """The URL of the output message type.""" - response_streaming: bool = betterproto.bool_field(5) + response_streaming: bool = betterproto2.bool_field(5) """If true, the response is streamed.""" - options: List["Option"] = betterproto.message_field(6, repeated=True) + options: List["Option"] = betterproto2.message_field(6, repeated=True) """Any metadata attached to the method.""" - syntax: "Syntax" = betterproto.enum_field(7, enum_default_value=lambda: Syntax.try_value(0)) + syntax: "Syntax" = betterproto2.enum_field(7, enum_default_value=lambda: Syntax.try_value(0)) """The source syntax of this method.""" @dataclass(eq=False, repr=False) -class Mixin(betterproto.Message): +class Mixin(betterproto2.Message): """ Declares an API Interface to be included in this interface. The including interface must redeclare all the methods from the included interface, but @@ -791,10 +791,10 @@ class Mixin(betterproto.Message): } """ - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """The fully qualified name of the interface which is included.""" - root: str = betterproto.string_field(2) + root: str = betterproto2.string_field(2) """ If non-empty specifies a path under which inherited HTTP paths are rooted. @@ -802,64 +802,64 @@ class Mixin(betterproto.Message): @dataclass(eq=False, repr=False) -class FileDescriptorSet(betterproto.Message): +class FileDescriptorSet(betterproto2.Message): """ The protocol compiler can output a FileDescriptorSet containing the .proto files it parses. """ - file: List["FileDescriptorProto"] = betterproto.message_field(1, repeated=True) + file: List["FileDescriptorProto"] = betterproto2.message_field(1, repeated=True) """ """ @dataclass(eq=False, repr=False) -class FileDescriptorProto(betterproto.Message): +class FileDescriptorProto(betterproto2.Message): """Describes a complete .proto file.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """file name, relative to root of source tree""" - package: str = betterproto.string_field(2) + package: str = betterproto2.string_field(2) """e.g. "foo", "foo.bar", etc.""" - dependency: List[str] = betterproto.string_field(3, repeated=True) + dependency: List[str] = betterproto2.string_field(3, repeated=True) """Names of files imported by this file.""" - public_dependency: List[int] = betterproto.int32_field(10, repeated=True) + public_dependency: List[int] = betterproto2.int32_field(10, repeated=True) """Indexes of the public imported files in the dependency list above.""" - weak_dependency: List[int] = betterproto.int32_field(11, repeated=True) + weak_dependency: List[int] = betterproto2.int32_field(11, repeated=True) """ Indexes of the weak imported files in the dependency list. For Google-internal migration only. Do not use. """ - message_type: List["DescriptorProto"] = betterproto.message_field(4, repeated=True) + message_type: List["DescriptorProto"] = betterproto2.message_field(4, repeated=True) """All top-level definitions in this file.""" - enum_type: List["EnumDescriptorProto"] = betterproto.message_field(5, repeated=True) + enum_type: List["EnumDescriptorProto"] = betterproto2.message_field(5, repeated=True) """ """ - service: List["ServiceDescriptorProto"] = betterproto.message_field(6, repeated=True) + service: List["ServiceDescriptorProto"] = betterproto2.message_field(6, repeated=True) """ """ - extension: List["FieldDescriptorProto"] = betterproto.message_field(7, repeated=True) + extension: List["FieldDescriptorProto"] = betterproto2.message_field(7, repeated=True) """ """ - options: "FileOptions" = betterproto.message_field(8) + options: "FileOptions" = betterproto2.message_field(8) """ """ - source_code_info: "SourceCodeInfo" = betterproto.message_field(9) + source_code_info: "SourceCodeInfo" = betterproto2.message_field(9) """ This field contains optional information about the original source code. You may safely remove this entire field without harming runtime @@ -867,7 +867,7 @@ class FileDescriptorProto(betterproto.Message): development tools. """ - syntax: str = betterproto.string_field(12) + syntax: str = betterproto2.string_field(12) """ The syntax of the proto file. The supported values are "proto2" and "proto3". @@ -875,55 +875,55 @@ class FileDescriptorProto(betterproto.Message): @dataclass(eq=False, repr=False) -class DescriptorProto(betterproto.Message): +class DescriptorProto(betterproto2.Message): """Describes a message type.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ """ - field: List["FieldDescriptorProto"] = betterproto.message_field(2, repeated=True) + field: List["FieldDescriptorProto"] = betterproto2.message_field(2, repeated=True) """ """ - extension: List["FieldDescriptorProto"] = betterproto.message_field(6, repeated=True) + extension: List["FieldDescriptorProto"] = betterproto2.message_field(6, repeated=True) """ """ - nested_type: List["DescriptorProto"] = betterproto.message_field(3, repeated=True) + nested_type: List["DescriptorProto"] = betterproto2.message_field(3, repeated=True) """ """ - enum_type: List["EnumDescriptorProto"] = betterproto.message_field(4, repeated=True) + enum_type: List["EnumDescriptorProto"] = betterproto2.message_field(4, repeated=True) """ """ - extension_range: List["DescriptorProtoExtensionRange"] = betterproto.message_field(5, repeated=True) + extension_range: List["DescriptorProtoExtensionRange"] = betterproto2.message_field(5, repeated=True) """ """ - oneof_decl: List["OneofDescriptorProto"] = betterproto.message_field(8, repeated=True) + oneof_decl: List["OneofDescriptorProto"] = betterproto2.message_field(8, repeated=True) """ """ - options: "MessageOptions" = betterproto.message_field(7) + options: "MessageOptions" = betterproto2.message_field(7) """ """ - reserved_range: List["DescriptorProtoReservedRange"] = betterproto.message_field(9, repeated=True) + reserved_range: List["DescriptorProtoReservedRange"] = betterproto2.message_field(9, repeated=True) """ """ - reserved_name: List[str] = betterproto.string_field(10, repeated=True) + reserved_name: List[str] = betterproto2.string_field(10, repeated=True) """ Reserved field names, which may not be used by fields in the same message. A given name may only be reserved once. @@ -931,66 +931,66 @@ class DescriptorProto(betterproto.Message): @dataclass(eq=False, repr=False) -class DescriptorProtoExtensionRange(betterproto.Message): +class DescriptorProtoExtensionRange(betterproto2.Message): """ """ - start: int = betterproto.int32_field(1) + start: int = betterproto2.int32_field(1) """Inclusive.""" - end: int = betterproto.int32_field(2) + end: int = betterproto2.int32_field(2) """Exclusive.""" - options: "ExtensionRangeOptions" = betterproto.message_field(3) + options: "ExtensionRangeOptions" = betterproto2.message_field(3) """ """ @dataclass(eq=False, repr=False) -class DescriptorProtoReservedRange(betterproto.Message): +class DescriptorProtoReservedRange(betterproto2.Message): """ Range of reserved tag numbers. Reserved tag numbers may not be used by fields or extension ranges in the same message. Reserved ranges may not overlap. """ - start: int = betterproto.int32_field(1) + start: int = betterproto2.int32_field(1) """Inclusive.""" - end: int = betterproto.int32_field(2) + end: int = betterproto2.int32_field(2) """Exclusive.""" @dataclass(eq=False, repr=False) -class ExtensionRangeOptions(betterproto.Message): +class ExtensionRangeOptions(betterproto2.Message): """ """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class FieldDescriptorProto(betterproto.Message): +class FieldDescriptorProto(betterproto2.Message): """Describes a field within a message.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ """ - number: int = betterproto.int32_field(3) + number: int = betterproto2.int32_field(3) """ """ - label: "FieldDescriptorProtoLabel" = betterproto.enum_field( + label: "FieldDescriptorProtoLabel" = betterproto2.enum_field( 4, enum_default_value=lambda: FieldDescriptorProtoLabel.try_value(0) ) """ """ - type: "FieldDescriptorProtoType" = betterproto.enum_field( + type: "FieldDescriptorProtoType" = betterproto2.enum_field( 5, enum_default_value=lambda: FieldDescriptorProtoType.try_value(0) ) """ @@ -998,7 +998,7 @@ class FieldDescriptorProto(betterproto.Message): are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. """ - type_name: str = betterproto.string_field(6) + type_name: str = betterproto2.string_field(6) """ For message and enum types, this is the name of the type. If the name starts with a '.', it is fully-qualified. Otherwise, C++-like scoping @@ -1007,13 +1007,13 @@ class FieldDescriptorProto(betterproto.Message): namespace). """ - extendee: str = betterproto.string_field(2) + extendee: str = betterproto2.string_field(2) """ For extensions, this is the name of the type being extended. It is resolved in the same manner as type_name. """ - default_value: str = betterproto.string_field(7) + default_value: str = betterproto2.string_field(7) """ For numeric types, contains the original text representation of the value. For booleans, "true" or "false". @@ -1022,13 +1022,13 @@ class FieldDescriptorProto(betterproto.Message): TODO(kenton): Base-64 encode? """ - oneof_index: Optional[int] = betterproto.int32_field(9, optional=True) + oneof_index: Optional[int] = betterproto2.int32_field(9, optional=True) """ If set, gives the index of a oneof in the containing type's oneof_decl list. This field is a member of that oneof. """ - json_name: str = betterproto.string_field(10) + json_name: str = betterproto2.string_field(10) """ JSON name of this field. The value is set by protocol compiler. If the user has set a "json_name" option on this field, that option's value @@ -1036,12 +1036,12 @@ class FieldDescriptorProto(betterproto.Message): it to camelCase. """ - options: "FieldOptions" = betterproto.message_field(8) + options: "FieldOptions" = betterproto2.message_field(8) """ """ - proto3_optional: bool = betterproto.bool_field(17) + proto3_optional: bool = betterproto2.bool_field(17) """ If true, this is a proto3 "optional". When a proto3 field is optional, it tracks presence regardless of field type. @@ -1068,47 +1068,47 @@ class FieldDescriptorProto(betterproto.Message): @dataclass(eq=False, repr=False) -class OneofDescriptorProto(betterproto.Message): +class OneofDescriptorProto(betterproto2.Message): """Describes a oneof.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ """ - options: "OneofOptions" = betterproto.message_field(2) + options: "OneofOptions" = betterproto2.message_field(2) """ """ @dataclass(eq=False, repr=False) -class EnumDescriptorProto(betterproto.Message): +class EnumDescriptorProto(betterproto2.Message): """Describes an enum type.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ """ - value: List["EnumValueDescriptorProto"] = betterproto.message_field(2, repeated=True) + value: List["EnumValueDescriptorProto"] = betterproto2.message_field(2, repeated=True) """ """ - options: "EnumOptions" = betterproto.message_field(3) + options: "EnumOptions" = betterproto2.message_field(3) """ """ - reserved_range: List["EnumDescriptorProtoEnumReservedRange"] = betterproto.message_field(4, repeated=True) + reserved_range: List["EnumDescriptorProtoEnumReservedRange"] = betterproto2.message_field(4, repeated=True) """ Range of reserved numeric values. Reserved numeric values may not be used by enum values in the same enum declaration. Reserved ranges may not overlap. """ - reserved_name: List[str] = betterproto.string_field(5, repeated=True) + reserved_name: List[str] = betterproto2.string_field(5, repeated=True) """ Reserved enum value names, which may not be reused. A given name may only be reserved once. @@ -1116,7 +1116,7 @@ class EnumDescriptorProto(betterproto.Message): @dataclass(eq=False, repr=False) -class EnumDescriptorProtoEnumReservedRange(betterproto.Message): +class EnumDescriptorProtoEnumReservedRange(betterproto2.Message): """ Range of reserved numeric values. Reserved values may not be used by entries in the same enum. Reserved ranges may not overlap. @@ -1126,87 +1126,87 @@ class EnumDescriptorProtoEnumReservedRange(betterproto.Message): domain. """ - start: int = betterproto.int32_field(1) + start: int = betterproto2.int32_field(1) """Inclusive.""" - end: int = betterproto.int32_field(2) + end: int = betterproto2.int32_field(2) """Inclusive.""" @dataclass(eq=False, repr=False) -class EnumValueDescriptorProto(betterproto.Message): +class EnumValueDescriptorProto(betterproto2.Message): """Describes a value within an enum.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ """ - number: int = betterproto.int32_field(2) + number: int = betterproto2.int32_field(2) """ """ - options: "EnumValueOptions" = betterproto.message_field(3) + options: "EnumValueOptions" = betterproto2.message_field(3) """ """ @dataclass(eq=False, repr=False) -class ServiceDescriptorProto(betterproto.Message): +class ServiceDescriptorProto(betterproto2.Message): """Describes a service.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ """ - method: List["MethodDescriptorProto"] = betterproto.message_field(2, repeated=True) + method: List["MethodDescriptorProto"] = betterproto2.message_field(2, repeated=True) """ """ - options: "ServiceOptions" = betterproto.message_field(3) + options: "ServiceOptions" = betterproto2.message_field(3) """ """ @dataclass(eq=False, repr=False) -class MethodDescriptorProto(betterproto.Message): +class MethodDescriptorProto(betterproto2.Message): """Describes a method of a service.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ """ - input_type: str = betterproto.string_field(2) + input_type: str = betterproto2.string_field(2) """ Input and output type names. These are resolved in the same way as FieldDescriptorProto.type_name, but must refer to a message type. """ - output_type: str = betterproto.string_field(3) + output_type: str = betterproto2.string_field(3) """ """ - options: "MethodOptions" = betterproto.message_field(4) + options: "MethodOptions" = betterproto2.message_field(4) """ """ - client_streaming: bool = betterproto.bool_field(5) + client_streaming: bool = betterproto2.bool_field(5) """Identifies if client streams multiple client messages""" - server_streaming: bool = betterproto.bool_field(6) + server_streaming: bool = betterproto2.bool_field(6) """Identifies if server streams multiple server messages""" @dataclass(eq=False, repr=False) -class FileOptions(betterproto.Message): +class FileOptions(betterproto2.Message): """ =================================================================== Options @@ -1241,7 +1241,7 @@ class FileOptions(betterproto.Message): to automatically assign option numbers. """ - java_package: str = betterproto.string_field(1) + java_package: str = betterproto2.string_field(1) """ Sets the Java package where classes generated from this .proto will be placed. By default, the proto package is used, but this is often @@ -1249,7 +1249,7 @@ class FileOptions(betterproto.Message): domain names. """ - java_outer_classname: str = betterproto.string_field(8) + java_outer_classname: str = betterproto2.string_field(8) """ If set, all the classes from the .proto file are wrapped in a single outer class with the given name. This applies to both Proto1 @@ -1258,7 +1258,7 @@ class FileOptions(betterproto.Message): explicitly choose the class name). """ - java_multiple_files: bool = betterproto.bool_field(10) + java_multiple_files: bool = betterproto2.bool_field(10) """ If set true, then the Java code generator will generate a separate .java file for each top-level message, enum, and service defined in the .proto @@ -1268,10 +1268,10 @@ class FileOptions(betterproto.Message): top-level extensions defined in the file. """ - java_generate_equals_and_hash: bool = betterproto.bool_field(20) + java_generate_equals_and_hash: bool = betterproto2.bool_field(20) """This option does nothing.""" - java_string_check_utf8: bool = betterproto.bool_field(27) + java_string_check_utf8: bool = betterproto2.bool_field(27) """ If set true, then the Java2 code generator will generate code that throws an exception whenever an attempt is made to assign a non-UTF-8 @@ -1281,14 +1281,14 @@ class FileOptions(betterproto.Message): This option has no effect on when used with the lite runtime. """ - optimize_for: "FileOptionsOptimizeMode" = betterproto.enum_field( + optimize_for: "FileOptionsOptimizeMode" = betterproto2.enum_field( 9, enum_default_value=lambda: FileOptionsOptimizeMode.try_value(0) ) """ """ - go_package: str = betterproto.string_field(11) + go_package: str = betterproto2.string_field(11) """ Sets the Go package where structs generated from this .proto will be placed. If omitted, the Go package will be derived from the following: @@ -1297,7 +1297,7 @@ class FileOptions(betterproto.Message): - Otherwise, the basename of the .proto file, without extension. """ - cc_generic_services: bool = betterproto.bool_field(16) + cc_generic_services: bool = betterproto2.bool_field(16) """ Should generic services be generated in each language? "Generic" services are not specific to any particular RPC system. They are generated by the @@ -1311,22 +1311,22 @@ class FileOptions(betterproto.Message): explicitly set them to true. """ - java_generic_services: bool = betterproto.bool_field(17) + java_generic_services: bool = betterproto2.bool_field(17) """ """ - py_generic_services: bool = betterproto.bool_field(18) + py_generic_services: bool = betterproto2.bool_field(18) """ """ - php_generic_services: bool = betterproto.bool_field(42) + php_generic_services: bool = betterproto2.bool_field(42) """ """ - deprecated: bool = betterproto.bool_field(23) + deprecated: bool = betterproto2.bool_field(23) """ Is this file deprecated? Depending on the target platform, this can emit Deprecated annotations @@ -1334,22 +1334,22 @@ class FileOptions(betterproto.Message): least, this is a formalization for deprecating files. """ - cc_enable_arenas: bool = betterproto.bool_field(31) + cc_enable_arenas: bool = betterproto2.bool_field(31) """ Enables the use of arenas for the proto messages in this file. This applies only to generated classes for C++. """ - objc_class_prefix: str = betterproto.string_field(36) + objc_class_prefix: str = betterproto2.string_field(36) """ Sets the objective c class prefix which is prepended to all objective c generated classes from this .proto. There is no default. """ - csharp_namespace: str = betterproto.string_field(37) + csharp_namespace: str = betterproto2.string_field(37) """Namespace for generated classes; defaults to the package.""" - swift_prefix: str = betterproto.string_field(39) + swift_prefix: str = betterproto2.string_field(39) """ By default Swift generators will take the proto package and CamelCase it replacing '.' with underscore and use that to prefix the types/symbols @@ -1357,34 +1357,34 @@ class FileOptions(betterproto.Message): to prefix the types/symbols defined. """ - php_class_prefix: str = betterproto.string_field(40) + php_class_prefix: str = betterproto2.string_field(40) """ Sets the php class prefix which is prepended to all php generated classes from this .proto. Default is empty. """ - php_namespace: str = betterproto.string_field(41) + php_namespace: str = betterproto2.string_field(41) """ Use this option to change the namespace of php generated classes. Default is empty. When this option is empty, the package name will be used for determining the namespace. """ - php_metadata_namespace: str = betterproto.string_field(44) + php_metadata_namespace: str = betterproto2.string_field(44) """ Use this option to change the namespace of php generated metadata classes. Default is empty. When this option is empty, the proto file name will be used for determining the namespace. """ - ruby_package: str = betterproto.string_field(45) + ruby_package: str = betterproto2.string_field(45) """ Use this option to change the package of ruby generated classes. Default is empty. When this option is not set, the package name will be used for determining the ruby package. """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """ The parser stores options it doesn't recognize here. See the documentation for the "Options" section above. @@ -1400,10 +1400,10 @@ def __post_init__(self) -> None: @dataclass(eq=False, repr=False) -class MessageOptions(betterproto.Message): +class MessageOptions(betterproto2.Message): """ """ - message_set_wire_format: bool = betterproto.bool_field(1) + message_set_wire_format: bool = betterproto2.bool_field(1) """ Set true to use the old proto1 MessageSet wire format for extensions. This is provided for backwards-compatibility with the MessageSet wire @@ -1425,14 +1425,14 @@ class MessageOptions(betterproto.Message): the protocol compiler. """ - no_standard_descriptor_accessor: bool = betterproto.bool_field(2) + no_standard_descriptor_accessor: bool = betterproto2.bool_field(2) """ Disables the generation of the standard "descriptor()" accessor, which can conflict with a field of the same name. This is meant to make migration from proto1 easier; new code should avoid fields named "descriptor". """ - deprecated: bool = betterproto.bool_field(3) + deprecated: bool = betterproto2.bool_field(3) """ Is this message deprecated? Depending on the target platform, this can emit Deprecated annotations @@ -1440,7 +1440,7 @@ class MessageOptions(betterproto.Message): this is a formalization for deprecating messages. """ - map_entry: bool = betterproto.bool_field(7) + map_entry: bool = betterproto2.bool_field(7) """ Whether the message is an automatically generated map entry type for the maps field. @@ -1465,15 +1465,15 @@ class MessageOptions(betterproto.Message): parser. """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class FieldOptions(betterproto.Message): +class FieldOptions(betterproto2.Message): """ """ - ctype: "FieldOptionsCType" = betterproto.enum_field(1, enum_default_value=lambda: FieldOptionsCType.try_value(0)) + ctype: "FieldOptionsCType" = betterproto2.enum_field(1, enum_default_value=lambda: FieldOptionsCType.try_value(0)) """ The ctype option instructs the C++ code generator to use a different representation of the field than it normally would. See the specific @@ -1481,7 +1481,7 @@ class FieldOptions(betterproto.Message): release -- sorry, we'll try to include it in a future version! """ - packed: bool = betterproto.bool_field(2) + packed: bool = betterproto2.bool_field(2) """ The packed option can be enabled for repeated primitive fields to enable a more efficient representation on the wire. Rather than repeatedly @@ -1490,7 +1490,9 @@ class FieldOptions(betterproto.Message): false will avoid using packed encoding. """ - jstype: "FieldOptionsJsType" = betterproto.enum_field(6, enum_default_value=lambda: FieldOptionsJsType.try_value(0)) + jstype: "FieldOptionsJsType" = betterproto2.enum_field( + 6, enum_default_value=lambda: FieldOptionsJsType.try_value(0) + ) """ The jstype option determines the JavaScript type used for values of the field. The option is permitted only for 64 bit integral and fixed types @@ -1505,7 +1507,7 @@ class FieldOptions(betterproto.Message): goog.math.Integer. """ - lazy: bool = betterproto.bool_field(5) + lazy: bool = betterproto2.bool_field(5) """ Should this field be parsed lazily? Lazy applies only to message-type fields. It means that when the outer message is initially parsed, the @@ -1536,7 +1538,7 @@ class FieldOptions(betterproto.Message): been parsed. """ - deprecated: bool = betterproto.bool_field(3) + deprecated: bool = betterproto2.bool_field(3) """ Is this field deprecated? Depending on the target platform, this can emit Deprecated annotations @@ -1544,32 +1546,32 @@ class FieldOptions(betterproto.Message): is a formalization for deprecating fields. """ - weak: bool = betterproto.bool_field(10) + weak: bool = betterproto2.bool_field(10) """For Google-internal migration only. Do not use.""" - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class OneofOptions(betterproto.Message): +class OneofOptions(betterproto2.Message): """ """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class EnumOptions(betterproto.Message): +class EnumOptions(betterproto2.Message): """ """ - allow_alias: bool = betterproto.bool_field(2) + allow_alias: bool = betterproto2.bool_field(2) """ Set this option to true to allow mapping different tag names to the same value. """ - deprecated: bool = betterproto.bool_field(3) + deprecated: bool = betterproto2.bool_field(3) """ Is this enum deprecated? Depending on the target platform, this can emit Deprecated annotations @@ -1577,15 +1579,15 @@ class EnumOptions(betterproto.Message): is a formalization for deprecating enums. """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class EnumValueOptions(betterproto.Message): +class EnumValueOptions(betterproto2.Message): """ """ - deprecated: bool = betterproto.bool_field(1) + deprecated: bool = betterproto2.bool_field(1) """ Is this enum value deprecated? Depending on the target platform, this can emit Deprecated annotations @@ -1593,15 +1595,15 @@ class EnumValueOptions(betterproto.Message): this is a formalization for deprecating enum values. """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class ServiceOptions(betterproto.Message): +class ServiceOptions(betterproto2.Message): """ """ - deprecated: bool = betterproto.bool_field(33) + deprecated: bool = betterproto2.bool_field(33) """ Note: Field numbers 1 through 32 are reserved for Google's internal RPC framework. We apologize for hoarding these numbers to ourselves, but @@ -1614,15 +1616,15 @@ class ServiceOptions(betterproto.Message): this is a formalization for deprecating services. """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class MethodOptions(betterproto.Message): +class MethodOptions(betterproto2.Message): """ """ - deprecated: bool = betterproto.bool_field(33) + deprecated: bool = betterproto2.bool_field(33) """ Note: Field numbers 1 through 32 are reserved for Google's internal RPC framework. We apologize for hoarding these numbers to ourselves, but @@ -1635,19 +1637,19 @@ class MethodOptions(betterproto.Message): this is a formalization for deprecating methods. """ - idempotency_level: "MethodOptionsIdempotencyLevel" = betterproto.enum_field( + idempotency_level: "MethodOptionsIdempotencyLevel" = betterproto2.enum_field( 34, enum_default_value=lambda: MethodOptionsIdempotencyLevel.try_value(0) ) """ """ - uninterpreted_option: List["UninterpretedOption"] = betterproto.message_field(999, repeated=True) + uninterpreted_option: List["UninterpretedOption"] = betterproto2.message_field(999, repeated=True) """The parser stores options it doesn't recognize here. See above.""" @dataclass(eq=False, repr=False) -class UninterpretedOption(betterproto.Message): +class UninterpretedOption(betterproto2.Message): """ A message representing a option the parser does not recognize. This only appears in options protos created by the compiler::Parser class. @@ -1657,45 +1659,45 @@ class UninterpretedOption(betterproto.Message): in them. """ - name: List["UninterpretedOptionNamePart"] = betterproto.message_field(2, repeated=True) + name: List["UninterpretedOptionNamePart"] = betterproto2.message_field(2, repeated=True) """ """ - identifier_value: str = betterproto.string_field(3) + identifier_value: str = betterproto2.string_field(3) """ The value of the uninterpreted option, in whatever type the tokenizer identified it as during parsing. Exactly one of these should be set. """ - positive_int_value: int = betterproto.uint64_field(4) + positive_int_value: int = betterproto2.uint64_field(4) """ """ - negative_int_value: int = betterproto.int64_field(5) + negative_int_value: int = betterproto2.int64_field(5) """ """ - double_value: float = betterproto.double_field(6) + double_value: float = betterproto2.double_field(6) """ """ - string_value: bytes = betterproto.bytes_field(7) + string_value: bytes = betterproto2.bytes_field(7) """ """ - aggregate_value: str = betterproto.string_field(8) + aggregate_value: str = betterproto2.string_field(8) """ """ @dataclass(eq=False, repr=False) -class UninterpretedOptionNamePart(betterproto.Message): +class UninterpretedOptionNamePart(betterproto2.Message): """ The name of the uninterpreted option. Each string represents a segment in a dot-separated name. is_extension is true iff a segment represents an @@ -1704,19 +1706,19 @@ class UninterpretedOptionNamePart(betterproto.Message): "foo.(bar.baz).qux". """ - name_part: str = betterproto.string_field(1) + name_part: str = betterproto2.string_field(1) """ """ - is_extension: bool = betterproto.bool_field(2) + is_extension: bool = betterproto2.bool_field(2) """ """ @dataclass(eq=False, repr=False) -class SourceCodeInfo(betterproto.Message): +class SourceCodeInfo(betterproto2.Message): """ =================================================================== Optional source code info @@ -1725,7 +1727,7 @@ class SourceCodeInfo(betterproto.Message): FileDescriptorProto was generated. """ - location: List["SourceCodeInfoLocation"] = betterproto.message_field(1, repeated=True) + location: List["SourceCodeInfoLocation"] = betterproto2.message_field(1, repeated=True) """ A Location identifies a piece of source code in a .proto file which corresponds to a particular definition. This information is intended @@ -1774,10 +1776,10 @@ class SourceCodeInfo(betterproto.Message): @dataclass(eq=False, repr=False) -class SourceCodeInfoLocation(betterproto.Message): +class SourceCodeInfoLocation(betterproto2.Message): """ """ - path: List[int] = betterproto.int32_field(1, repeated=True) + path: List[int] = betterproto2.int32_field(1, repeated=True) """ Identifies which part of the FileDescriptorProto was defined at this location. @@ -1804,7 +1806,7 @@ class SourceCodeInfoLocation(betterproto.Message): of the label to the terminating semicolon). """ - span: List[int] = betterproto.int32_field(2, repeated=True) + span: List[int] = betterproto2.int32_field(2, repeated=True) """ Always has exactly three or four elements: start line, start column, end line (optional, otherwise assumed same as start line), end column. @@ -1813,7 +1815,7 @@ class SourceCodeInfoLocation(betterproto.Message): 1 to each before displaying to a user. """ - leading_comments: str = betterproto.string_field(3) + leading_comments: str = betterproto2.string_field(3) """ If this SourceCodeInfo represents a complete declaration, these are any comments appearing before and after the declaration which appear to be @@ -1864,26 +1866,26 @@ class SourceCodeInfoLocation(betterproto.Message): // ignored detached comments. """ - trailing_comments: str = betterproto.string_field(4) + trailing_comments: str = betterproto2.string_field(4) """ """ - leading_detached_comments: List[str] = betterproto.string_field(6, repeated=True) + leading_detached_comments: List[str] = betterproto2.string_field(6, repeated=True) """ """ @dataclass(eq=False, repr=False) -class GeneratedCodeInfo(betterproto.Message): +class GeneratedCodeInfo(betterproto2.Message): """ Describes the relationship between generated code and its original source file. A GeneratedCodeInfo message is associated with only one generated source file, but may contain references to different source .proto files. """ - annotation: List["GeneratedCodeInfoAnnotation"] = betterproto.message_field(1, repeated=True) + annotation: List["GeneratedCodeInfoAnnotation"] = betterproto2.message_field(1, repeated=True) """ An Annotation connects some span of text in generated code to an element of its generating .proto file. @@ -1891,25 +1893,25 @@ class GeneratedCodeInfo(betterproto.Message): @dataclass(eq=False, repr=False) -class GeneratedCodeInfoAnnotation(betterproto.Message): +class GeneratedCodeInfoAnnotation(betterproto2.Message): """ """ - path: List[int] = betterproto.int32_field(1, repeated=True) + path: List[int] = betterproto2.int32_field(1, repeated=True) """ Identifies the element in the original source .proto file. This field is formatted the same as SourceCodeInfo.Location.path. """ - source_file: str = betterproto.string_field(2) + source_file: str = betterproto2.string_field(2) """Identifies the filesystem path to the original source .proto.""" - begin: int = betterproto.int32_field(3) + begin: int = betterproto2.int32_field(3) """ Identifies the starting offset in bytes in the generated code that relates to the identified object. """ - end: int = betterproto.int32_field(4) + end: int = betterproto2.int32_field(4) """ Identifies the ending offset in bytes in the generated code that relates to the identified offset. The end offset should be one past @@ -1918,7 +1920,7 @@ class GeneratedCodeInfoAnnotation(betterproto.Message): @dataclass(eq=False, repr=False) -class Duration(betterproto.Message): +class Duration(betterproto2.Message): """ A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond @@ -1980,14 +1982,14 @@ class Duration(betterproto.Message): microsecond should be expressed in JSON format as "3.000001s". """ - seconds: int = betterproto.int64_field(1) + seconds: int = betterproto2.int64_field(1) """ Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years """ - nanos: int = betterproto.int32_field(2) + nanos: int = betterproto2.int32_field(2) """ Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 @@ -1999,7 +2001,7 @@ class Duration(betterproto.Message): @dataclass(eq=False, repr=False) -class Empty(betterproto.Message): +class Empty(betterproto2.Message): """ A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request @@ -2016,7 +2018,7 @@ class Empty(betterproto.Message): @dataclass(eq=False, repr=False) -class FieldMask(betterproto.Message): +class FieldMask(betterproto2.Message): """ `FieldMask` represents a set of symbolic field paths, for example: @@ -2218,12 +2220,12 @@ class FieldMask(betterproto.Message): `INVALID_ARGUMENT` error if any path is unmappable. """ - paths: List[str] = betterproto.string_field(1, repeated=True) + paths: List[str] = betterproto2.string_field(1, repeated=True) """The set of field mask paths.""" @dataclass(eq=False, repr=False) -class Struct(betterproto.Message): +class Struct(betterproto2.Message): """ `Struct` represents a structured data value, consisting of fields which map to dynamically typed values. In some languages, `Struct` @@ -2235,7 +2237,7 @@ class Struct(betterproto.Message): The JSON representation for `Struct` is JSON object. """ - fields: Dict[str, "Value"] = betterproto.map_field(1, betterproto.TYPE_STRING, betterproto.TYPE_MESSAGE) + fields: Dict[str, "Value"] = betterproto2.map_field(1, betterproto2.TYPE_STRING, betterproto2.TYPE_MESSAGE) """Unordered map of dynamically typed values.""" @hybridmethod @@ -2255,7 +2257,7 @@ def from_dict(self, value: Mapping[str, Any]) -> Self: def to_dict( self, - casing: betterproto.Casing = betterproto.Casing.CAMEL, + casing: betterproto2.Casing = betterproto2.Casing.CAMEL, include_default_values: bool = False, ) -> Dict[str, Any]: output = {**self.fields} @@ -2266,7 +2268,7 @@ def to_dict( @dataclass(eq=False, repr=False) -class Value(betterproto.Message): +class Value(betterproto2.Message): """ `Value` represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a @@ -2276,39 +2278,41 @@ class Value(betterproto.Message): The JSON representation for `Value` is JSON value. """ - null_value: "NullValue" = betterproto.enum_field(1, enum_default_value=lambda: NullValue.try_value(0), group="kind") + null_value: "NullValue" = betterproto2.enum_field( + 1, enum_default_value=lambda: NullValue.try_value(0), group="kind" + ) """Represents a null value.""" - number_value: float = betterproto.double_field(2, group="kind") + number_value: float = betterproto2.double_field(2, group="kind") """Represents a double value.""" - string_value: str = betterproto.string_field(3, group="kind") + string_value: str = betterproto2.string_field(3, group="kind") """Represents a string value.""" - bool_value: bool = betterproto.bool_field(4, group="kind") + bool_value: bool = betterproto2.bool_field(4, group="kind") """Represents a boolean value.""" - struct_value: "Struct" = betterproto.message_field(5, group="kind") + struct_value: "Struct" = betterproto2.message_field(5, group="kind") """Represents a structured value.""" - list_value: "ListValue" = betterproto.message_field(6, group="kind") + list_value: "ListValue" = betterproto2.message_field(6, group="kind") """Represents a repeated `Value`.""" @dataclass(eq=False, repr=False) -class ListValue(betterproto.Message): +class ListValue(betterproto2.Message): """ `ListValue` is a wrapper around a repeated field of values. The JSON representation for `ListValue` is JSON array. """ - values: List["Value"] = betterproto.message_field(1, repeated=True) + values: List["Value"] = betterproto2.message_field(1, repeated=True) """Repeated field of dynamically typed values.""" @dataclass(eq=False, repr=False) -class Timestamp(betterproto.Message): +class Timestamp(betterproto2.Message): """ A Timestamp represents a point in time independent of any time zone or local calendar, encoded as a count of seconds and fractions of seconds at @@ -2393,14 +2397,14 @@ class Timestamp(betterproto.Message): ) to obtain a formatter capable of generating timestamps in this format. """ - seconds: int = betterproto.int64_field(1) + seconds: int = betterproto2.int64_field(1) """ Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive. """ - nanos: int = betterproto.int32_field(2) + nanos: int = betterproto2.int32_field(2) """ Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values @@ -2410,108 +2414,108 @@ class Timestamp(betterproto.Message): @dataclass(eq=False, repr=False) -class DoubleValue(betterproto.Message): +class DoubleValue(betterproto2.Message): """ Wrapper message for `double`. The JSON representation for `DoubleValue` is JSON number. """ - value: float = betterproto.double_field(1) + value: float = betterproto2.double_field(1) """The double value.""" @dataclass(eq=False, repr=False) -class FloatValue(betterproto.Message): +class FloatValue(betterproto2.Message): """ Wrapper message for `float`. The JSON representation for `FloatValue` is JSON number. """ - value: float = betterproto.float_field(1) + value: float = betterproto2.float_field(1) """The float value.""" @dataclass(eq=False, repr=False) -class Int64Value(betterproto.Message): +class Int64Value(betterproto2.Message): """ Wrapper message for `int64`. The JSON representation for `Int64Value` is JSON string. """ - value: int = betterproto.int64_field(1) + value: int = betterproto2.int64_field(1) """The int64 value.""" @dataclass(eq=False, repr=False) -class UInt64Value(betterproto.Message): +class UInt64Value(betterproto2.Message): """ Wrapper message for `uint64`. The JSON representation for `UInt64Value` is JSON string. """ - value: int = betterproto.uint64_field(1) + value: int = betterproto2.uint64_field(1) """The uint64 value.""" @dataclass(eq=False, repr=False) -class Int32Value(betterproto.Message): +class Int32Value(betterproto2.Message): """ Wrapper message for `int32`. The JSON representation for `Int32Value` is JSON number. """ - value: int = betterproto.int32_field(1) + value: int = betterproto2.int32_field(1) """The int32 value.""" @dataclass(eq=False, repr=False) -class UInt32Value(betterproto.Message): +class UInt32Value(betterproto2.Message): """ Wrapper message for `uint32`. The JSON representation for `UInt32Value` is JSON number. """ - value: int = betterproto.uint32_field(1) + value: int = betterproto2.uint32_field(1) """The uint32 value.""" @dataclass(eq=False, repr=False) -class BoolValue(betterproto.Message): +class BoolValue(betterproto2.Message): """ Wrapper message for `bool`. The JSON representation for `BoolValue` is JSON `true` and `false`. """ - value: bool = betterproto.bool_field(1) + value: bool = betterproto2.bool_field(1) """The bool value.""" @dataclass(eq=False, repr=False) -class StringValue(betterproto.Message): +class StringValue(betterproto2.Message): """ Wrapper message for `string`. The JSON representation for `StringValue` is JSON string. """ - value: str = betterproto.string_field(1) + value: str = betterproto2.string_field(1) """The string value.""" @dataclass(eq=False, repr=False) -class BytesValue(betterproto.Message): +class BytesValue(betterproto2.Message): """ Wrapper message for `bytes`. The JSON representation for `BytesValue` is JSON string. """ - value: bytes = betterproto.bytes_field(1) + value: bytes = betterproto2.bytes_field(1) """The bytes value.""" diff --git a/src/betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py b/src/betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py index fb93bd3e..89ac5943 100644 --- a/src/betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py +++ b/src/betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py @@ -1,17 +1,17 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: google/protobuf/compiler/plugin.proto -# plugin: python-betterproto +# plugin: python-betterproto2 # This file has been @generated from dataclasses import dataclass from typing import List -import betterproto +import betterproto2 import betterproto2_compiler.lib.google.protobuf as betterproto_lib_google_protobuf -class CodeGeneratorResponseFeature(betterproto.Enum): +class CodeGeneratorResponseFeature(betterproto2.Enum): """Sync with code_generator.h.""" FEATURE_NONE = 0 @@ -20,13 +20,13 @@ class CodeGeneratorResponseFeature(betterproto.Enum): @dataclass(eq=False, repr=False) -class Version(betterproto.Message): +class Version(betterproto2.Message): """The version number of protocol compiler.""" - major: int = betterproto.int32_field(1) - minor: int = betterproto.int32_field(2) - patch: int = betterproto.int32_field(3) - suffix: str = betterproto.string_field(4) + major: int = betterproto2.int32_field(1) + minor: int = betterproto2.int32_field(2) + patch: int = betterproto2.int32_field(3) + suffix: str = betterproto2.string_field(4) """ A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should be empty for mainline stable releases. @@ -34,20 +34,20 @@ class Version(betterproto.Message): @dataclass(eq=False, repr=False) -class CodeGeneratorRequest(betterproto.Message): +class CodeGeneratorRequest(betterproto2.Message): """An encoded CodeGeneratorRequest is written to the plugin's stdin.""" - file_to_generate: List[str] = betterproto.string_field(1, repeated=True) + file_to_generate: List[str] = betterproto2.string_field(1, repeated=True) """ The .proto files that were explicitly listed on the command-line. The code generator should generate code only for these files. Each file's descriptor will be included in proto_file, below. """ - parameter: str = betterproto.string_field(2) + parameter: str = betterproto2.string_field(2) """The generator parameter passed on the command-line.""" - proto_file: List["betterproto_lib_google_protobuf.FileDescriptorProto"] = betterproto.message_field( + proto_file: List["betterproto_lib_google_protobuf.FileDescriptorProto"] = betterproto2.message_field( 15, repeated=True ) """ @@ -72,7 +72,7 @@ class CodeGeneratorRequest(betterproto.Message): fully qualified. """ - source_file_descriptors: List["betterproto_lib_google_protobuf.FileDescriptorProto"] = betterproto.message_field( + source_file_descriptors: List["betterproto_lib_google_protobuf.FileDescriptorProto"] = betterproto2.message_field( 17, repeated=True ) """ @@ -81,15 +81,15 @@ class CodeGeneratorRequest(betterproto.Message): files_to_generate. """ - compiler_version: "Version" = betterproto.message_field(3) + compiler_version: "Version" = betterproto2.message_field(3) """The version number of protocol compiler.""" @dataclass(eq=False, repr=False) -class CodeGeneratorResponse(betterproto.Message): +class CodeGeneratorResponse(betterproto2.Message): """The plugin writes an encoded CodeGeneratorResponse to stdout.""" - error: str = betterproto.string_field(1) + error: str = betterproto2.string_field(1) """ Error message. If non-empty, code generation failed. The plugin process should exit with status code zero even if it reports an error in this way. @@ -101,13 +101,13 @@ class CodeGeneratorResponse(betterproto.Message): exiting with a non-zero status code. """ - supported_features: int = betterproto.uint64_field(2) + supported_features: int = betterproto2.uint64_field(2) """ A bitmask of supported features that the code generator supports. This is a bitwise "or" of values from the Feature enum. """ - minimum_edition: int = betterproto.int32_field(3) + minimum_edition: int = betterproto2.int32_field(3) """ The minimum edition this plugin supports. This will be treated as an Edition enum, but we want to allow unknown values. It should be specified @@ -115,7 +115,7 @@ class CodeGeneratorResponse(betterproto.Message): effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. """ - maximum_edition: int = betterproto.int32_field(4) + maximum_edition: int = betterproto2.int32_field(4) """ The maximum edition this plugin supports. This will be treated as an Edition enum, but we want to allow unknown values. It should be specified @@ -123,14 +123,14 @@ class CodeGeneratorResponse(betterproto.Message): effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. """ - file: List["CodeGeneratorResponseFile"] = betterproto.message_field(15, repeated=True) + file: List["CodeGeneratorResponseFile"] = betterproto2.message_field(15, repeated=True) @dataclass(eq=False, repr=False) -class CodeGeneratorResponseFile(betterproto.Message): +class CodeGeneratorResponseFile(betterproto2.Message): """Represents a single generated file.""" - name: str = betterproto.string_field(1) + name: str = betterproto2.string_field(1) """ The file name, relative to the output directory. The name must not contain "." or ".." components and must be relative, not be absolute (so, @@ -145,7 +145,7 @@ class CodeGeneratorResponseFile(betterproto.Message): CodeGeneratorResponse before writing files to disk. """ - insertion_point: str = betterproto.string_field(2) + insertion_point: str = betterproto2.string_field(2) """ If non-empty, indicates that the named file should already exist, and the content here is to be inserted into that file at a defined insertion @@ -186,10 +186,10 @@ class CodeGeneratorResponseFile(betterproto.Message): If |insertion_point| is present, |name| must also be present. """ - content: str = betterproto.string_field(15) + content: str = betterproto2.string_field(15) """The file contents.""" - generated_code_info: "betterproto_lib_google_protobuf.GeneratedCodeInfo" = betterproto.message_field(16) + generated_code_info: "betterproto_lib_google_protobuf.GeneratedCodeInfo" = betterproto2.message_field(16) """ Information describing the file content being inserted. If an insertion point is used, this information will be appropriately offset and inserted diff --git a/src/betterproto2_compiler/plugin/models.py b/src/betterproto2_compiler/plugin/models.py index f228c8e1..78bcce1c 100644 --- a/src/betterproto2_compiler/plugin/models.py +++ b/src/betterproto2_compiler/plugin/models.py @@ -389,7 +389,7 @@ def get_field_string(self) -> str: """Construct string representation of this field as a field.""" name = f"{self.py_name}" field_args = ", ".join(([""] + self.betterproto_field_args) if self.betterproto_field_args else []) - betterproto_field_type = f"betterproto.{self.field_type}_field({self.proto_obj.number}{field_args})" + betterproto_field_type = f"betterproto2.{self.field_type}_field({self.proto_obj.number}{field_args})" if self.py_name in dir(builtins): self.parent.builtins_types.add(self.py_name) return f'{name}: "{self.annotation}" = {betterproto_field_type}' @@ -421,7 +421,7 @@ def field_wraps(self) -> Optional[str]: if match_wrapper: wrapped_type = "TYPE_" + match_wrapper.group(1).upper() if hasattr(betterproto2_compiler, wrapped_type): - return f"betterproto.{wrapped_type}" + return f"betterproto2.{wrapped_type}" return None @property @@ -548,7 +548,7 @@ def ready(self) -> None: @property def betterproto_field_args(self) -> List[str]: - return [f"betterproto.{self.proto_k_type}", f"betterproto.{self.proto_v_type}"] + return [f"betterproto2.{self.proto_k_type}", f"betterproto2.{self.proto_v_type}"] @property def field_type(self) -> str: diff --git a/src/betterproto2_compiler/templates/header.py.j2 b/src/betterproto2_compiler/templates/header.py.j2 index 9b1e5219..498ab9f0 100644 --- a/src/betterproto2_compiler/templates/header.py.j2 +++ b/src/betterproto2_compiler/templates/header.py.j2 @@ -2,7 +2,7 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # sources: {{ ', '.join(output_file.input_filenames) }} -# plugin: python-betterproto +# plugin: python-betterproto2 # This file has been @generated __all__ = ( @@ -36,9 +36,9 @@ from dataclasses import dataclass {% endfor %} {% endif %} -import betterproto +import betterproto2 {% if output_file.services %} -from betterproto.grpc.grpclib_server import ServiceBase +from betterproto2.grpc.grpclib_server import ServiceBase import grpclib {% endif %} @@ -46,5 +46,5 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: import grpclib.server - from betterproto.grpc.grpclib_client import MetadataLike + from betterproto2.grpc.grpclib_client import MetadataLike from grpclib.metadata import Deadline diff --git a/src/betterproto2_compiler/templates/template.py.j2 b/src/betterproto2_compiler/templates/template.py.j2 index 23529bc2..3db14c37 100644 --- a/src/betterproto2_compiler/templates/template.py.j2 +++ b/src/betterproto2_compiler/templates/template.py.j2 @@ -1,5 +1,5 @@ {% for _, enum in output_file.enums|dictsort(by="key") %} -class {{ enum.py_name }}(betterproto.Enum): +class {{ enum.py_name }}(betterproto2.Enum): {% if enum.comment %} """ {{ enum.comment | indent(4) }} @@ -31,7 +31,7 @@ class {{ enum.py_name }}(betterproto.Enum): {% else %} @dataclass(eq=False, repr=False) {% endif %} -class {{ message.py_name }}(betterproto.Message): +class {{ message.py_name }}(betterproto2.Message): {% if message.comment %} """ {{ message.comment | indent(4) }} @@ -71,7 +71,7 @@ class {{ message.py_name }}(betterproto.Message): {% endfor %} {% for _, service in output_file.services|dictsort(by="key") %} -class {{ service.py_name }}Stub(betterproto.ServiceStub): +class {{ service.py_name }}Stub(betterproto2.ServiceStub): {% if service.comment %} """ {{ service.comment | indent(4) }}