Skip to content

Commit 3780eaa

Browse files
committed
apidocsの修正
1 parent 1e5bf48 commit 3780eaa

File tree

9 files changed

+84
-68
lines changed

9 files changed

+84
-68
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ publish:
3131
rm -fr build/ dist/ annofabapi.egg-info
3232

3333
docs:
34-
cd docs && make html
34+
cd docs && pipenv run make html
3535
@echo "\033[95m\n\nBuild successful! View the docs homepage at docs/_build/html/index.html.\n\033[0m"

annofabapi/api.py

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ def login(self) -> Tuple[Dict[str, Any], requests.Response]:
201201
"""
202202
ログイン
203203
204+
205+
204206
Returns:
205207
Tuple[Token, requests.Response]
206208
@@ -225,6 +227,8 @@ def logout(self) -> Optional[Tuple[Dict[str, Any], requests.Response]]:
225227
ログアウト
226228
ログインしていないときはNoneを返す。
227229
230+
231+
228232
Returns:
229233
Tuple[Token, requests.Response]. ログインしていないときはNone.
230234
@@ -247,6 +251,8 @@ def refresh_token(self
247251
トークン リフレッシュ
248252
ログインしていないときはNoneを返す。
249253
254+
255+
250256
Returns:
251257
Tuple[Token, requests.Response]. ログインしていないときはNone.
252258
"""

annofabapi/api2.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import functools
2-
import json
31
import logging
42
from typing import Any, Callable, Dict, List, Optional, Tuple, Union # pylint: disable=unused-import
53

6-
import backoff
74
import requests
8-
from requests.auth import AuthBase
95

106
import annofabapi.utils
117
from annofabapi.api import AnnofabApi
@@ -81,9 +77,8 @@ def _request_wrapper(self,
8177
kwargs.update({"cookies": self.cookies})
8278

8379
# HTTP Requestを投げる
84-
response: requests.Response = getattr(self.api.session,
85-
http_method.lower())(
86-
url, **kwargs)
80+
response = getattr(self.api.session, http_method.lower())(url,
81+
**kwargs)
8782

8883
# CloudFrontから403 Errorが発生したとき
8984
if response.status_code == requests.codes.forbidden and response.headers.get(
@@ -109,7 +104,8 @@ def _get_signed_access_v2(self, url_path: str):
109104
#########################################
110105
# Public Method : Cache
111106
#########################################
112-
def get_signed_access_v2(self, query_params: Dict[str, Any]) -> Tuple[Dict[str, Any], requests.Response]:
107+
def get_signed_access_v2(self, query_params: Dict[str, Any]
108+
) -> Tuple[Dict[str, Any], requests.Response]:
113109
"""
114110
Signed Cookieを取得して、インスタンスに保持する。
115111

annofabapi/generated_api2.py

+44-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# flake8: noqa: W291
22
# pylint: disable=too-many-lines,trailing-whitespace
3-
43
"""
54
AbstractAnnofabApi2のヘッダ部分
65
注意:このファイルはopenapi-generatorで自動生成される。詳細は generate/README.mdを参照
76
"""
87

98
import abc
10-
import warnings
9+
import warnings # pylint: disable=unused-import
1110
from typing import Any, Dict, List, Optional, Tuple, Union # pylint: disable=unused-import
1211

1312
import requests
@@ -27,12 +26,17 @@ def _request_wrapper(self,
2726
request_body: Optional[Any] = None
2827
) -> Tuple[Any, requests.Response]:
2928
pass
29+
3030
#########################################
3131
# Public Method : AfAnnotationSpecsV2Api
3232
# NOTE: This method is auto generated by OpenAPI Generator
3333
#########################################
3434

35-
def get_annotation_specs_v2(self, project_id: str, query_params: Optional[Dict[str, Any]] = None, ) -> Tuple[Any, requests.Response]: # noqa: E501
35+
def get_annotation_specs_v2(
36+
self,
37+
project_id: str,
38+
query_params: Optional[Dict[str, Any]] = None,
39+
) -> Tuple[Any, requests.Response]: # noqa: E501
3640
"""アノテーション仕様取得
3741
3842
@@ -54,12 +58,16 @@ def get_annotation_specs_v2(self, project_id: str, query_params: Optional[Dict[s
5458
'query_params': query_params,
5559
}
5660
return self._request_wrapper(http_method, url_path, **keyword_params)
61+
5762
#########################################
5863
# Public Method : AfProjectV2Api
5964
# NOTE: This method is auto generated by OpenAPI Generator
6065
#########################################
6166

62-
def get_project_cache_v2(self, project_id: str, ) -> Tuple[Any, requests.Response]: # noqa: E501
67+
def get_project_cache_v2(
68+
self,
69+
project_id: str,
70+
) -> Tuple[Any, requests.Response]: # noqa: E501
6371
"""キャッシュレコード
6472
6573
@@ -75,15 +83,19 @@ def get_project_cache_v2(self, project_id: str, ) -> Tuple[Any, requests.Respons
7583
"""
7684
url_path = f'/projects/{project_id}/cache'
7785
http_method = 'GET'
78-
keyword_params: Dict[str, Any] = {
79-
}
86+
keyword_params: Dict[str, Any] = {}
8087
return self._request_wrapper(http_method, url_path, **keyword_params)
88+
8189
#########################################
8290
# Public Method : AfStatisticsV2Api
8391
# NOTE: This method is auto generated by OpenAPI Generator
8492
#########################################
8593

86-
def get_account_statistics_v2(self, project_id: str, query_params: Optional[Dict[str, Any]] = None, ) -> Tuple[Any, requests.Response]: # noqa: E501
94+
def get_account_statistics_v2(
95+
self,
96+
project_id: str,
97+
query_params: Optional[Dict[str, Any]] = None,
98+
) -> Tuple[Any, requests.Response]: # noqa: E501
8799
"""ユーザー別タスク集計取得
88100
89101
@@ -106,7 +118,11 @@ def get_account_statistics_v2(self, project_id: str, query_params: Optional[Dict
106118
}
107119
return self._request_wrapper(http_method, url_path, **keyword_params)
108120

109-
def get_inspection_statistics_v2(self, project_id: str, query_params: Optional[Dict[str, Any]] = None, ) -> Tuple[Any, requests.Response]: # noqa: E501
121+
def get_inspection_statistics_v2(
122+
self,
123+
project_id: str,
124+
query_params: Optional[Dict[str, Any]] = None,
125+
) -> Tuple[Any, requests.Response]: # noqa: E501
110126
"""検査コメント集計取得
111127
112128
@@ -129,7 +145,11 @@ def get_inspection_statistics_v2(self, project_id: str, query_params: Optional[D
129145
}
130146
return self._request_wrapper(http_method, url_path, **keyword_params)
131147

132-
def get_label_statistics_v2(self, project_id: str, query_params: Optional[Dict[str, Any]] = None, ) -> Tuple[Any, requests.Response]: # noqa: E501
148+
def get_label_statistics_v2(
149+
self,
150+
project_id: str,
151+
query_params: Optional[Dict[str, Any]] = None,
152+
) -> Tuple[Any, requests.Response]: # noqa: E501
133153
"""ラベル別アノテーション数集計取得
134154
135155
@@ -152,7 +172,11 @@ def get_label_statistics_v2(self, project_id: str, query_params: Optional[Dict[s
152172
}
153173
return self._request_wrapper(http_method, url_path, **keyword_params)
154174

155-
def get_task_phase_statistics_v2(self, project_id: str, query_params: Optional[Dict[str, Any]] = None, ) -> Tuple[Any, requests.Response]: # noqa: E501
175+
def get_task_phase_statistics_v2(
176+
self,
177+
project_id: str,
178+
query_params: Optional[Dict[str, Any]] = None,
179+
) -> Tuple[Any, requests.Response]: # noqa: E501
156180
"""フェーズ別タスク集計取得
157181
158182
@@ -175,7 +199,11 @@ def get_task_phase_statistics_v2(self, project_id: str, query_params: Optional[D
175199
}
176200
return self._request_wrapper(http_method, url_path, **keyword_params)
177201

178-
def get_task_statistics_v2(self, project_id: str, query_params: Optional[Dict[str, Any]] = None, ) -> Tuple[Any, requests.Response]: # noqa: E501
202+
def get_task_statistics_v2(
203+
self,
204+
project_id: str,
205+
query_params: Optional[Dict[str, Any]] = None,
206+
) -> Tuple[Any, requests.Response]: # noqa: E501
179207
"""タスク集計取得
180208
181209
@@ -198,7 +226,11 @@ def get_task_statistics_v2(self, project_id: str, query_params: Optional[Dict[st
198226
}
199227
return self._request_wrapper(http_method, url_path, **keyword_params)
200228

201-
def get_worktime_statistics_v2(self, project_id: str, query_params: Optional[Dict[str, Any]] = None, ) -> Tuple[Any, requests.Response]: # noqa: E501
229+
def get_worktime_statistics_v2(
230+
self,
231+
project_id: str,
232+
query_params: Optional[Dict[str, Any]] = None,
233+
) -> Tuple[Any, requests.Response]: # noqa: E501
202234
"""タスク作業時間集計取得
203235
204236

annofabapi/resource.py

+6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ def __init__(self, login_user_id: str, login_password: str):
1616
login_password: AnnoFabにログインするときのパスワード
1717
1818
"""
19+
20+
#: AnnofabApi Instance
1921
self.api = AnnofabApi(login_user_id, login_password)
22+
23+
#: Wrapper Instance
2024
self.wrapper = Wrapper(self.api)
25+
26+
#: AnnofabApi2 Instance
2127
self.api2 = AnnofabApi2(self.api)
2228

2329

annofabapi/utils.py

+8
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ def log_error_response(arg_logger: logging.Logger,
1616
response: requests.Response):
1717
"""
1818
HTTP Statusが400以上ならば、loggerにresponse/request情報を出力する
19+
1920
Args:
2021
arg_logger: logger
2122
response: Response
23+
2224
"""
2325

2426
if 400 <= response.status_code < 600:
@@ -34,9 +36,11 @@ def log_error_response(arg_logger: logging.Logger,
3436
def download(url: str, dest_path: str):
3537
"""
3638
HTTP GETで取得した内容をファイルに保存する(ダウンロードする)
39+
3740
Args:
3841
url: ダウンロード対象のURL
3942
dest_path: 保存先ファイルのパス
43+
4044
"""
4145
response = requests.get(url)
4246
response.raise_for_status()
@@ -50,8 +54,12 @@ def download(url: str, dest_path: str):
5054
def str_now() -> str:
5155
"""
5256
現在日時をISO8601 formatで取得する。
57+
58+
59+
5360
Returns:
5461
ISO 8601 formatの現在日時
62+
5563
"""
5664
d = datetime.datetime.now(dateutil.tz.tzlocal())
5765
return d.isoformat(timespec='milliseconds')

docs/annofabapi.rst

+12-46
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,36 @@
11
annofabapi package
22
==================
33

4-
Submodules
5-
----------
64

7-
annofabapi.api module
8-
---------------------
5+
annofabapi.AnnofabApi class
6+
---------------------------
7+
.. autoclass:: annofabapi.AnnofabApi
8+
:inherited-members:
99

10-
.. automodule:: annofabapi.api
11-
:members:
12-
:undoc-members:
13-
:show-inheritance:
1410

15-
annofabapi.exceptions module
16-
----------------------------
11+
annofabapi.Wrapper class
12+
------------------------
13+
.. autoclass:: annofabapi.Wrapper
14+
:inherited-members:
1715

18-
.. automodule:: annofabapi.exceptions
19-
:members:
20-
:undoc-members:
21-
:show-inheritance:
2216

23-
annofabapi.generated\_api module
24-
--------------------------------
17+
annofabapi.AnnofabApi2 class
18+
----------------------------
19+
.. autoclass:: annofabapi.AnnofabApi2
20+
:inherited-members:
2521

26-
.. automodule:: annofabapi.generated_api
27-
:members:
28-
:undoc-members:
29-
:show-inheritance:
3022

3123
annofabapi.resource module
3224
--------------------------
3325

3426
.. automodule:: annofabapi.resource
3527
:members:
36-
:undoc-members:
37-
:show-inheritance:
38-
39-
annofabapi.typing module
40-
------------------------
4128

42-
.. automodule:: annofabapi.typing
43-
:members:
44-
:undoc-members:
45-
:show-inheritance:
4629

4730
annofabapi.utils module
4831
-----------------------
4932

5033
.. automodule:: annofabapi.utils
5134
:members:
52-
:undoc-members:
53-
:show-inheritance:
5435

55-
annofabapi.wrapper module
56-
-------------------------
57-
58-
.. automodule:: annofabapi.wrapper
59-
:members:
60-
:undoc-members:
61-
:show-inheritance:
6236

63-
64-
Module contents
65-
---------------
66-
67-
.. automodule:: annofabapi
68-
:members:
69-
:undoc-members:
70-
:show-inheritance:

tests/test_api2.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@
4444

4545
def test_project():
4646
assert type(service.api2.get_project_cache_v2(project_id))
47-

tox.ini

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ disable =
5757
empty-docstring,
5858
redefined-builtin,
5959

60+
# ===== Custom =====
61+
protected-access,
62+
6063
[aliases]
6164
test=pytest
6265

0 commit comments

Comments
 (0)