Skip to content

Commit 4b0decf

Browse files
committed
Update generated code after rebase
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
1 parent f6ce520 commit 4b0decf

32 files changed

+1193
-487
lines changed

mypy_protobuf/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def write_enum_values(
418418
scl = scl_prefix + [i]
419419
# Class level
420420
if class_attributes and val.options.deprecated:
421-
self._write_line("@property")
421+
self._write_line(self._property())
422422
self._write_deprecation_warning(
423423
scl + [d.EnumValueDescriptorProto.OPTIONS_FIELD_NUMBER] + [d.EnumOptions.DEPRECATED_FIELD_NUMBER],
424424
"This enum value has been marked as deprecated using proto enum value options.",
@@ -576,7 +576,7 @@ def write_messages(
576576
scl_field = scl + [d.DescriptorProto.FIELD_FIELD_NUMBER, idx]
577577
deprecation_scl_field = scl_field + [d.FieldDescriptorProto.OPTIONS_FIELD_NUMBER] + [d.FieldOptions.DEPRECATED_FIELD_NUMBER]
578578
if field.options.deprecated:
579-
wl("@property")
579+
wl(self._property())
580580
self._write_deprecation_warning(
581581
deprecation_scl_field,
582582
"This field has been marked as deprecated using proto field options.",
@@ -966,7 +966,7 @@ def type_str(method: d.MethodDescriptorProto, is_async: bool) -> str:
966966
type_annotation = type_str(method, is_async=is_async)
967967

968968
if is_deprecated:
969-
wl("@property")
969+
wl(self._property())
970970
self._write_deprecation_warning(
971971
scl + [d.MethodDescriptorProto.OPTIONS_FIELD_NUMBER, d.MethodOptions.DEPRECATED_FIELD_NUMBER],
972972
"This method has been marked as deprecated using proto method options.",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ line-length = 10000
1313
[tool.isort]
1414
profile = "black"
1515
skip_gitignore = true
16-
extend_skip_glob = ["*_pb2.py", "*_pb2_grpc.py"]
16+
extend_skip_glob = ["*_pb2.py"]
1717

1818
[tool.mypy]
1919
strict = true

test/generated/google/protobuf/api_pb2.pyi

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ if sys.version_info >= (3, 10):
4747
else:
4848
import typing_extensions as _typing_extensions
4949

50+
if sys.version_info >= (3, 13):
51+
from warnings import deprecated as _deprecated
52+
else:
53+
from typing_extensions import deprecated as _deprecated
54+
5055
DESCRIPTOR: _google_protobuf_descriptor.FileDescriptor
5156

5257
@_typing.final
@@ -173,18 +178,42 @@ class Method(_google_protobuf_message.Message):
173178
"""The URL of the output message type."""
174179
response_streaming: _builtins.bool
175180
"""If true, the response is streamed."""
176-
syntax: google.protobuf.type_pb2.Syntax.ValueType
177-
"""The source syntax of this method.
181+
@_builtins.property
182+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
183+
def syntax(self) -> google.protobuf.type_pb2.Syntax.ValueType:
184+
"""The source syntax of this method.
178185
179-
This field should be ignored, instead the syntax should be inherited from
180-
Api. This is similar to Field and EnumValue.
181-
"""
182-
edition: _builtins.str
183-
"""The source edition string, only valid when syntax is SYNTAX_EDITIONS.
186+
This field should be ignored, instead the syntax should be inherited from
187+
Api. This is similar to Field and EnumValue.
188+
"""
189+
190+
@syntax.setter
191+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
192+
def syntax(self, value: google.protobuf.type_pb2.Syntax.ValueType) -> None:
193+
"""The source syntax of this method.
194+
195+
This field should be ignored, instead the syntax should be inherited from
196+
Api. This is similar to Field and EnumValue.
197+
"""
198+
199+
@_builtins.property
200+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
201+
def edition(self) -> _builtins.str:
202+
"""The source edition string, only valid when syntax is SYNTAX_EDITIONS.
203+
204+
This field should be ignored, instead the edition should be inherited from
205+
Api. This is similar to Field and EnumValue.
206+
"""
207+
208+
@edition.setter
209+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
210+
def edition(self, value: _builtins.str) -> None:
211+
"""The source edition string, only valid when syntax is SYNTAX_EDITIONS.
212+
213+
This field should be ignored, instead the edition should be inherited from
214+
Api. This is similar to Field and EnumValue.
215+
"""
184216

185-
This field should be ignored, instead the edition should be inherited from
186-
Api. This is similar to Field and EnumValue.
187-
"""
188217
@_builtins.property
189218
def options(self) -> _google_protobuf_internal_containers.RepeatedCompositeFieldContainer[google.protobuf.type_pb2.Option]:
190219
"""Any metadata attached to the method."""

test/generated/google/protobuf/descriptor_pb2.pyi

Lines changed: 79 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ if sys.version_info >= (3, 10):
2424
else:
2525
import typing_extensions as _typing_extensions
2626

27+
if sys.version_info >= (3, 13):
28+
from warnings import deprecated as _deprecated
29+
else:
30+
from typing_extensions import deprecated as _deprecated
31+
2732
DESCRIPTOR: _google_protobuf_descriptor.FileDescriptor
2833

2934
class _Edition:
@@ -979,8 +984,16 @@ class FileOptions(_google_protobuf_message.Message):
979984
generated to contain the file's getDescriptor() method as well as any
980985
top-level extensions defined in the file.
981986
"""
982-
java_generate_equals_and_hash: _builtins.bool
983-
"""This option does nothing."""
987+
@_builtins.property
988+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
989+
def java_generate_equals_and_hash(self) -> _builtins.bool:
990+
"""This option does nothing."""
991+
992+
@java_generate_equals_and_hash.setter
993+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
994+
def java_generate_equals_and_hash(self, value: _builtins.bool) -> None:
995+
"""This option does nothing."""
996+
984997
java_string_check_utf8: _builtins.bool
985998
"""A proto2 file can set this to true to opt in to UTF-8 checking for Java,
986999
which will throw an exception if invalid UTF-8 is parsed from the wire or
@@ -1167,18 +1180,36 @@ class MessageOptions(_google_protobuf_message.Message):
11671180
instead. The option should only be implicitly set by the proto compiler
11681181
parser.
11691182
"""
1170-
deprecated_legacy_json_field_conflicts: _builtins.bool
1171-
"""Enable the legacy handling of JSON field name conflicts. This lowercases
1172-
and strips underscored from the fields before comparison in proto3 only.
1173-
The new behavior takes `json_name` into account and applies to proto2 as
1174-
well.
1183+
@_builtins.property
1184+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
1185+
def deprecated_legacy_json_field_conflicts(self) -> _builtins.bool:
1186+
"""Enable the legacy handling of JSON field name conflicts. This lowercases
1187+
and strips underscored from the fields before comparison in proto3 only.
1188+
The new behavior takes `json_name` into account and applies to proto2 as
1189+
well.
1190+
1191+
This should only be used as a temporary measure against broken builds due
1192+
to the change in behavior for JSON field name conflicts.
1193+
1194+
TODO This is legacy behavior we plan to remove once downstream
1195+
teams have had time to migrate.
1196+
"""
11751197

1176-
This should only be used as a temporary measure against broken builds due
1177-
to the change in behavior for JSON field name conflicts.
1198+
@deprecated_legacy_json_field_conflicts.setter
1199+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
1200+
def deprecated_legacy_json_field_conflicts(self, value: _builtins.bool) -> None:
1201+
"""Enable the legacy handling of JSON field name conflicts. This lowercases
1202+
and strips underscored from the fields before comparison in proto3 only.
1203+
The new behavior takes `json_name` into account and applies to proto2 as
1204+
well.
1205+
1206+
This should only be used as a temporary measure against broken builds due
1207+
to the change in behavior for JSON field name conflicts.
1208+
1209+
TODO This is legacy behavior we plan to remove once downstream
1210+
teams have had time to migrate.
1211+
"""
11781212

1179-
TODO This is legacy behavior we plan to remove once downstream
1180-
teams have had time to migrate.
1181-
"""
11821213
@_builtins.property
11831214
def features(self) -> Global___FeatureSet:
11841215
"""Any features defined in the specific edition.
@@ -1463,10 +1494,20 @@ class FieldOptions(_google_protobuf_message.Message):
14631494
for accessors, or it will be completely ignored; in the very least, this
14641495
is a formalization for deprecating fields.
14651496
"""
1466-
weak: _builtins.bool
1467-
"""DEPRECATED. DO NOT USE!
1468-
For Google-internal migration only. Do not use.
1469-
"""
1497+
@_builtins.property
1498+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
1499+
def weak(self) -> _builtins.bool:
1500+
"""DEPRECATED. DO NOT USE!
1501+
For Google-internal migration only. Do not use.
1502+
"""
1503+
1504+
@weak.setter
1505+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
1506+
def weak(self, value: _builtins.bool) -> None:
1507+
"""DEPRECATED. DO NOT USE!
1508+
For Google-internal migration only. Do not use.
1509+
"""
1510+
14701511
debug_redact: _builtins.bool
14711512
"""Indicate that the field value should not be printed out when using debug
14721513
formats, e.g. when the field contains sensitive credentials.
@@ -1565,14 +1606,28 @@ class EnumOptions(_google_protobuf_message.Message):
15651606
for the enum, or it will be completely ignored; in the very least, this
15661607
is a formalization for deprecating enums.
15671608
"""
1568-
deprecated_legacy_json_field_conflicts: _builtins.bool
1569-
"""Enable the legacy handling of JSON field name conflicts. This lowercases
1570-
and strips underscored from the fields before comparison in proto3 only.
1571-
The new behavior takes `json_name` into account and applies to proto2 as
1572-
well.
1573-
TODO Remove this legacy behavior once downstream teams have
1574-
had time to migrate.
1575-
"""
1609+
@_builtins.property
1610+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
1611+
def deprecated_legacy_json_field_conflicts(self) -> _builtins.bool:
1612+
"""Enable the legacy handling of JSON field name conflicts. This lowercases
1613+
and strips underscored from the fields before comparison in proto3 only.
1614+
The new behavior takes `json_name` into account and applies to proto2 as
1615+
well.
1616+
TODO Remove this legacy behavior once downstream teams have
1617+
had time to migrate.
1618+
"""
1619+
1620+
@deprecated_legacy_json_field_conflicts.setter
1621+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
1622+
def deprecated_legacy_json_field_conflicts(self, value: _builtins.bool) -> None:
1623+
"""Enable the legacy handling of JSON field name conflicts. This lowercases
1624+
and strips underscored from the fields before comparison in proto3 only.
1625+
The new behavior takes `json_name` into account and applies to proto2 as
1626+
well.
1627+
TODO Remove this legacy behavior once downstream teams have
1628+
had time to migrate.
1629+
"""
1630+
15761631
@_builtins.property
15771632
def features(self) -> Global___FeatureSet:
15781633
"""Any features defined in the specific edition.

test/generated/google/protobuf/edition_unittest_pb2.pyi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,23 @@ class TestDeprecatedFields(_google_protobuf_message.Message):
748748
DEPRECATED_MESSAGE_FIELD_NUMBER: _builtins.int
749749
DEPRECATED_INT32_IN_ONEOF_FIELD_NUMBER: _builtins.int
750750
NESTED_FIELD_NUMBER: _builtins.int
751-
deprecated_int32: _builtins.int
752-
deprecated_int32_in_oneof: _builtins.int
753751
@_builtins.property
752+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
753+
def deprecated_int32(self) -> _builtins.int: ...
754+
@deprecated_int32.setter
755+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
756+
def deprecated_int32(self, value: _builtins.int) -> None: ...
757+
@_builtins.property
758+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
759+
def deprecated_int32_in_oneof(self) -> _builtins.int: ...
760+
@deprecated_int32_in_oneof.setter
761+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
762+
def deprecated_int32_in_oneof(self, value: _builtins.int) -> None: ...
763+
@_builtins.property
764+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
754765
def deprecated_repeated_string(self) -> _google_protobuf_internal_containers.RepeatedScalarFieldContainer[_builtins.str]: ...
755766
@_builtins.property
767+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
756768
def deprecated_message(self) -> Global___TestAllTypes.NestedMessage: ...
757769
@_builtins.property
758770
def nested(self) -> Global___TestDeprecatedFields: ...

test/generated/google/protobuf/unittest_lite_pb2.pyi

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ if sys.version_info >= (3, 10):
2323
else:
2424
import typing_extensions as _typing_extensions
2525

26+
if sys.version_info >= (3, 13):
27+
from warnings import deprecated as _deprecated
28+
else:
29+
from typing_extensions import deprecated as _deprecated
30+
2631
DESCRIPTOR: _google_protobuf_descriptor.FileDescriptor
2732

2833
class _ForeignEnumLite:
@@ -627,10 +632,26 @@ class TestDeprecatedLite(_google_protobuf_message.Message):
627632
DEPRECATED_FIELD2_FIELD_NUMBER: _builtins.int
628633
DEPRECATED_FIELD3_FIELD_NUMBER: _builtins.int
629634
DEPRECATED_FIELD4_FIELD_NUMBER: _builtins.int
630-
deprecated_field: _builtins.int
631-
deprecated_field2: _builtins.int
632-
deprecated_field3: _builtins.str
633635
@_builtins.property
636+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
637+
def deprecated_field(self) -> _builtins.int: ...
638+
@deprecated_field.setter
639+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
640+
def deprecated_field(self, value: _builtins.int) -> None: ...
641+
@_builtins.property
642+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
643+
def deprecated_field2(self) -> _builtins.int: ...
644+
@deprecated_field2.setter
645+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
646+
def deprecated_field2(self, value: _builtins.int) -> None: ...
647+
@_builtins.property
648+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
649+
def deprecated_field3(self) -> _builtins.str: ...
650+
@deprecated_field3.setter
651+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
652+
def deprecated_field3(self, value: _builtins.str) -> None: ...
653+
@_builtins.property
654+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
634655
def deprecated_field4(self) -> Global___TestDeprecatedLite: ...
635656
def __init__(
636657
self,

test/generated/google/protobuf/unittest_pb2.pyi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,23 @@ class TestDeprecatedFields(_google_protobuf_message.Message):
772772
DEPRECATED_MESSAGE_FIELD_NUMBER: _builtins.int
773773
DEPRECATED_INT32_IN_ONEOF_FIELD_NUMBER: _builtins.int
774774
NESTED_FIELD_NUMBER: _builtins.int
775-
deprecated_int32: _builtins.int
776-
deprecated_int32_in_oneof: _builtins.int
777775
@_builtins.property
776+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
777+
def deprecated_int32(self) -> _builtins.int: ...
778+
@deprecated_int32.setter
779+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
780+
def deprecated_int32(self, value: _builtins.int) -> None: ...
781+
@_builtins.property
782+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
783+
def deprecated_int32_in_oneof(self) -> _builtins.int: ...
784+
@deprecated_int32_in_oneof.setter
785+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
786+
def deprecated_int32_in_oneof(self, value: _builtins.int) -> None: ...
787+
@_builtins.property
788+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
778789
def deprecated_repeated_string(self) -> _google_protobuf_internal_containers.RepeatedScalarFieldContainer[_builtins.str]: ...
779790
@_builtins.property
791+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
780792
def deprecated_message(self) -> Global___TestAllTypes.NestedMessage: ...
781793
@_builtins.property
782794
def nested(self) -> Global___TestDeprecatedFields: ...

test/generated/google/protobuf/unittest_redaction_pb2.pyi

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ if sys.version_info >= (3, 10):
2020
else:
2121
import typing_extensions as _typing_extensions
2222

23+
if sys.version_info >= (3, 13):
24+
from warnings import deprecated as _deprecated
25+
else:
26+
from typing_extensions import deprecated as _deprecated
27+
2328
DESCRIPTOR: _google_protobuf_descriptor.FileDescriptor
2429

2530
class _MetaAnnotatedEnum:
@@ -138,7 +143,12 @@ class TestRedactedMessage(_google_protobuf_message.Message):
138143
TEST_DIRECT_MESSAGE_ENUM_FIELD_NUMBER: _builtins.int
139144
TEST_NESTED_MESSAGE_ENUM_FIELD_NUMBER: _builtins.int
140145
TEST_REDACTED_MESSAGE_ENUM_FIELD_NUMBER: _builtins.int
141-
text_field: _builtins.str
146+
@_builtins.property
147+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
148+
def text_field(self) -> _builtins.str: ...
149+
@text_field.setter
150+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
151+
def text_field(self, value: _builtins.str) -> None: ...
142152
meta_annotated: _builtins.str
143153
repeated_meta_annotated: _builtins.str
144154
unredacted_repeated_annotations: _builtins.str

test/generated/testproto/grpc/dummy_pb2.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ class DeprecatedRequest(_google_protobuf_message.Message):
5959
DESCRIPTOR: _google_protobuf_descriptor.Descriptor
6060

6161
OLD_FIELD_FIELD_NUMBER: _builtins.int
62-
old_field: _builtins.str
62+
@_builtins.property
63+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
64+
def old_field(self) -> _builtins.str: ...
65+
@old_field.setter
66+
@_deprecated("""This field has been marked as deprecated using proto field options.""")
67+
def old_field(self, value: _builtins.str) -> None: ...
6368
def __init__(
6469
self,
6570
*,

0 commit comments

Comments
 (0)