8000 Simplify code: delete py_input_message (#614) · AdrienVannson/python-betterproto@8d25c96 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d25c96

Browse files
Simplify code: delete py_input_message (danielgtaylor#614)
1 parent 8fdcb38 commit 8d25c96

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

src/betterproto/plugin/models.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -755,30 +755,6 @@ def route(self) -> str:
755755
)
756756
return f"/{package_part}{self.parent.proto_name}/{self.proto_name}"
757757

758-
@property
759-
def py_input_message(self) -> Optional[MessageCompiler]:
760-
"""Find the input message object.
761-
762-
Returns
763-
-------
764-
Optional[MessageCompiler]
765-
Method instance representing the input message.
766-
If not input message could be found or there are no
767-
input messages, None is returned.
768-
"""
769-
package, name = parse_source_type_name(self.proto_obj.input_type)
770-
771-
# Nested types are currently flattened without dots.
772-
# Todo: keep a fully quantified name in types, that is
773-
# comparable with method.input_type
774-
for msg in self.request.all_messages:
775-
if (
776-
msg.py_name == pythonize_class_name(name.replace(".", ""))
777-
and msg.output_file.package == package
778-
):
779-
return msg
780-
return None
781-
782758
@property
783759
def py_input_message_type(self) -> str:
784760
"""String representation of the Python type corresponding to the

src/betterproto/templates/template.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class {{ service.py_name }}Stub(betterproto.ServiceStub):
7474
{% for method in service.methods %}
7575
async def {{ method.py_name }}(self
7676
{%- if not method.client_streaming -%}
77-
{%- if method.py_input_message -%}, {{ method.py_input_message_param }}: "{{ method.py_input_message_type }}"{%- endif -%}
77+
, {{ method.py_input_message_param }}: "{{ method.py_input_message_type }}"
7878
{%- else -%}
7979
{# Client streaming: need a request iterator instead #}
8080
, {{ method.py_input_message_param }}_iterator: {{ output_file.typing_compiler.union(output_file.typing_compiler.async_iterable(method.py_input_message_type), output_file.typing_compiler.iterable(method.py_input_message_type)) }}
@@ -153,7 +153,7 @@ class {{ service.py_name }}Base(ServiceBase):
153153
{% for method in service.methods %}
154154
async def {{ method.py_name }}(self
155155
{%- if not method.client_streaming -%}
156-
{%- if method.py_input_message -%}, {{ method.py_input_message_param }}: "{{ method.py_input_message_type }}"{%- endif -%}
156+
, {{ method.py_input_message_param }}: "{{ method.py_input_message_type }}"
157157
{%- else -%}
158158
{# Client streaming: need a request iterator instead #}
159159
, {{ method.py_input_message_param }}_iterator: {{ output_file.typing_compiler.async_iterator(method.py_input_message_type) }}

0 commit comments

Comments
 (0)
0