Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 04414e6

Browse files
committed
Move deprecated function
1 parent 9a23d3f commit 04414e6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/betterproto2_compiler/plugin/models.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ def comment(self) -> str:
162162
"""
163163
return get_comment(proto_file=self.source_file, path=self.path)
164164

165-
@property
166-
def deprecated(self) -> bool:
167-
return self.proto_obj.options and self.proto_obj.options.deprecated
168-
169165

170166
@dataclass(kw_only=True)
171167
class PluginRequestCompiler:
@@ -248,6 +244,10 @@ def proto_name(self) -> str:
248244
def py_name(self) -> str:
249245
return pythonize_class_name(self.proto_name)
250246

247+
@property
248+
def deprecated(self) -> bool:
249+
return self.proto_obj.options and self.proto_obj.options.deprecated
250+
251251
@property
252252
def deprecated_fields(self) -> Iterator[str]:
253253
for f in self.fields:
@@ -333,6 +333,10 @@ def betterproto_field_args(self) -> list[str]:
333333
args.append(f"default_factory=lambda: {self.py_type}.try_value(0)")
334334
return args
335335

336+
@property
337+
def deprecated(self) -> bool:
338+
return self.proto_obj.options and self.proto_obj.options.deprecated
339+
336340
@property
337341
def use_builtins(self) -> bool:
338342
return self.py_type in self.message.builtins_types or (
@@ -634,3 +638,7 @@ def client_streaming(self) -> bool:
634638
@property
635639
def server_streaming(self) -> bool:
636640
return self.proto_obj.server_streaming
641+
642+
@property
643+
def deprecated(self) -> bool:
644+
return self.proto_obj.options and self.proto_obj.options.deprecated

src/betterproto2_compiler/templates/template.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class {{ service.py_name }}Stub(betterproto2.ServiceStub):
112112
"""
113113
{% endif %}
114114

115-
{% if method.proto_obj.options and method.proto_obj.options.deprecated %}
115+
{% if method.deprecated %}
116116
warnings.warn("{{ service.py_name }}.{{ method.py_name }} is deprecated", DeprecationWarning)
117117
{% endif %}
118118

0 commit comments

Comments
 (0)