Skip to content

Commit 054ac96

Browse files
Merge pull request #1055 from appwrite/pla-2684
chore: improve docstrings for python
2 parents 184e612 + 5aafbbe commit 054ac96

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

templates/python/package/services/service.py.twig

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ..service import Service
2-
from typing import List
2+
from typing import List, Dict, Any
33
from ..exception import AppwriteException
44
{% set added = [] %}
55
{% for method in service.methods %}
@@ -24,12 +24,38 @@ from ..enums.{{ name | caseSnake }} import {{ name | caseUcfirst }};
2424

2525
class {{ service.name | caseUcfirst }}(Service):
2626

27-
def __init__(self, client):
27+
def __init__(self, client) -> None:
2828
super({{ service.name | caseUcfirst }}, self).__init__(client)
2929
{% for method in service.methods %}
3030

31-
def {{ method.name | caseSnake }}(self{% if method.parameters.all|length > 0 %}, {% endif %}{% for parameter in method.parameters.all %}{{ parameter.name | escapeKeyword | caseSnake }}: {{ parameter | getPropertyType(method) | raw }}{% if not parameter.required %} = None{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, on_progress = None{% endif %}):
32-
"""{{method.title}}"""
31+
def {{ method.name | caseSnake }}(self{% if method.parameters.all|length > 0 %}, {% endif %}{% for parameter in method.parameters.all %}{{ parameter.name | escapeKeyword | caseSnake }}: {{ parameter | getPropertyType(method) | raw }}{% if not parameter.required %} = None{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, on_progress = None{% endif %}) -> {% if method.type == 'webAuth' %}str{% else %}Dict[str, Any]{% endif %}:
32+
"""
33+
{% autoescape false %}{{ method.description | replace({"\n": "\n "}) }}{% endautoescape %}
34+
{% if method.parameters.all|length > 0 or 'multipart/form-data' in method.consumes %}
35+
36+
Parameters
37+
----------
38+
{% for parameter in method.parameters.all %}{{ parameter.name | escapeKeyword | caseSnake }} : {{ parameter | getPropertyType(method) | raw }}
39+
{% autoescape false %}{{ parameter.description | replace({"\n": "\n "}) }}{% endautoescape %}
40+
41+
{% endfor %}{% if 'multipart/form-data' in method.consumes %}
42+
on_progress : callable, optional
43+
Optional callback for upload progress
44+
{% endif %}{% endif %}
45+
46+
Returns
47+
-------
48+
{% if method.type == 'webAuth' %}str
49+
Authentication response as a string
50+
{% else %}Dict[str, Any]
51+
API response as a dictionary
52+
{% endif %}
53+
54+
Raises
55+
------
56+
AppwriteException
57+
If API request fails
58+
"""
3359

3460
api_path = '{{ method.path }}'
3561
{{ include('python/base/params.twig') }}

0 commit comments

Comments
 (0)