This repository was archived by the owner on Jun 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +45
-18
lines changed
src/betterproto2_compiler/templates Expand file tree Collapse file tree 3 files changed +45
-18
lines changed Original file line number Diff line number Diff line change @@ -10,24 +10,7 @@ class {% block class_name %}{% endblock %}({% block inherit_from %}{% endblock %
10
10
{% block class_content %}{% endblock %}
11
11
12
12
{% for method in service .methods %}
13
- async def {{ method.py_name }}(self
14
- {% - if not method .client_streaming -%}
15
- , message:
16
- {% - if method .is_input_msg_empty -%}
17
- "{{ method.py_input_message_type }} | None" = None
18
- {% - else -%}
19
- "{{ method.py_input_message_type }}"
20
- {% - endif -%}
21
- {% - else -%}
22
- {# Client streaming: need a request iterator instead #}
23
- , messages: "AsyncIterable[{{ method.py_input_message_type }}] | Iterable[{{ method.py_input_message_type }}]"
24
- {% - endif -%}
25
- ,
26
- *
27
- , timeout: "float | None" = None
28
- , deadline: "Deadline | None" = None
29
- , metadata: "MetadataLike | None" = None
30
- ) -> "{% if method .server_streaming %} AsyncIterator[{{ method.py_output_message_type }}]{% else %} {{ method.py_output_message_type }}{% endif %} ":
13
+ {% block method_definition scoped required %}{% endblock %}
31
14
{% if method .comment %}
32
15
"""
33
16
{{ method.comment | indent(8) }}
Original file line number Diff line number Diff line change 3
3
{# Class definition #}
4
4
{% block class_name %} {{ service.py_name }}Stub{% endblock %}
5
5
{% block inherit_from %} betterproto2.ServiceStub{% endblock %}
6
+
7
+ {# Methods definition #}
8
+ {% block method_definition %}
9
+ async def {{ method.py_name }}(self
10
+ {% - if not method .client_streaming -%}
11
+ , message:
12
+ {% - if method .is_input_msg_empty -%}
13
+ "{{ method.py_input_message_type }} | None" = None
14
+ {% - else -%}
15
+ "{{ method.py_input_message_type }}"
16
+ {% - endif -%}
17
+ {% - else -%}
18
+ {# Client streaming: need a request iterator instead #}
19
+ , messages: "AsyncIterable[{{ method.py_input_message_type }}] | Iterable[{{ method.py_input_message_type }}]"
20
+ {% - endif -%}
21
+ ,
22
+ *
23
+ , timeout: "float | None" = None
24
+ , deadline: "Deadline | None" = None
25
+ , metadata: "MetadataLike | None" = None
26
+ ) -> "{% if method .server_streaming %} AsyncIterator[{{ method.py_output_message_type }}]{% else %} {{ method.py_output_message_type }}{% endif %} ":
27
+ {% endblock %}
Original file line number Diff line number Diff line change 8
8
def __init__(self, channel: grpc.Channel):
9
9
self._channel = channel
10
10
{% endblock %}
11
+
12
+ {# Methods definition #}
13
+ {% block method_definition %}
14
+ def {{ method.py_name }}(self
15
+ {% - if not method .client_streaming -%}
16
+ , message:
17
+ {% - if method .is_input_msg_empty -%}
18
+ "{{ method.py_input_message_type }} | None" = None
19
+ {% - else -%}
20
+ "{{ method.py_input_message_type }}"
21
+ {% - endif -%}
22
+ {% - else -%}
23
+ {# Client streaming: need a request iterator instead #}
24
+ , messages: "Iterable[{{ method.py_input_message_type }}]"
25
+ {% - endif -%}
26
+ ,
27
+ *
28
+ , timeout: "float | None" = None
29
+ , deadline: "Deadline | None" = None
30
+ , metadata: "MetadataLike | None" = None
31
+ ) -> "{% if method .server_streaming %} Iterator[{{ method.py_output_message_type }}]{% else %} {{ method.py_output_message_type }}{% endif %} ":
32
+ {% endblock %}
You can’t perform that action at this time.
0 commit comments