Skip to content

Commit 32f0f77

Browse files
authored
warnings.warnのメッセージを分かりやすくする (#376)
* warnings.warnのメッセージをわかりやすくする * version up
1 parent cba9fc4 commit 32f0f77

File tree

6 files changed

+74
-19
lines changed

6 files changed

+74
-19
lines changed

annofabapi/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.50.1"
1+
__version__ = "0.50.2"

annofabapi/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,9 @@ def get_labor_control(self, query_params: Optional[Dict[str, Any]] = None) -> Tu
325325
326326
327327
"""
328-
warnings.warn("deprecated", FutureWarning)
329-
328+
warnings.warn(
329+
"annofabapi.AnnofabApi.get_labor_control() is deprecated and will be removed.", FutureWarning, stacklevel=2
330+
)
330331
url_path = "/labor-control"
331332
http_method = "GET"
332333
keyword_params: Dict[str, Any] = {

annofabapi/generated_api.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,11 @@ def get_project_task_history_events_url(self, project_id: str, **kwargs) -> Tupl
21372137
21382138
21392139
"""
2140-
warnings.warn("deprecated", FutureWarning)
2140+
warnings.warn(
2141+
"annofabapi.AnnofabApi.get_project_task_history_events_url() is deprecated and will be removed.",
2142+
FutureWarning,
2143+
stacklevel=2,
2144+
)
21412145
url_path = f"/projects/{project_id}/rawdata/task_history_events"
21422146
http_method = "GET"
21432147
keyword_params: Dict[str, Any] = {}
@@ -2419,7 +2423,11 @@ def get_account_statistics(self, project_id: str, **kwargs) -> Tuple[Any, reques
24192423
24202424
24212425
"""
2422-
warnings.warn("deprecated", FutureWarning)
2426+
warnings.warn(
2427+
"annofabapi.AnnofabApi.get_account_statistics() is deprecated and will be removed.",
2428+
FutureWarning,
2429+
stacklevel=2,
2430+
)
24232431
url_path = f"/projects/{project_id}/statistics/accounts"
24242432
http_method = "GET"
24252433
keyword_params: Dict[str, Any] = {}
@@ -2474,7 +2482,11 @@ def get_inspection_statistics(self, project_id: str, **kwargs) -> Tuple[Any, req
24742482
24752483
24762484
"""
2477-
warnings.warn("deprecated", FutureWarning)
2485+
warnings.warn(
2486+
"annofabapi.AnnofabApi.get_inspection_statistics() is deprecated and will be removed.",
2487+
FutureWarning,
2488+
stacklevel=2,
2489+
)
24782490
url_path = f"/projects/{project_id}/statistics/inspections"
24792491
http_method = "GET"
24802492
keyword_params: Dict[str, Any] = {}
@@ -2605,7 +2617,11 @@ def get_task_phase_statistics(self, project_id: str, **kwargs) -> Tuple[Any, req
26052617
26062618
26072619
"""
2608-
warnings.warn("deprecated", FutureWarning)
2620+
warnings.warn(
2621+
"annofabapi.AnnofabApi.get_task_phase_statistics() is deprecated and will be removed.",
2622+
FutureWarning,
2623+
stacklevel=2,
2624+
)
26092625
url_path = f"/projects/{project_id}/statistics/task-phases"
26102626
http_method = "GET"
26112627
keyword_params: Dict[str, Any] = {}
@@ -2630,7 +2646,11 @@ def get_task_statistics(self, project_id: str, **kwargs) -> Tuple[Any, requests.
26302646
26312647
26322648
"""
2633-
warnings.warn("deprecated", FutureWarning)
2649+
warnings.warn(
2650+
"annofabapi.AnnofabApi.get_task_statistics() is deprecated and will be removed.",
2651+
FutureWarning,
2652+
stacklevel=2,
2653+
)
26342654
url_path = f"/projects/{project_id}/statistics/tasks"
26352655
http_method = "GET"
26362656
keyword_params: Dict[str, Any] = {}
@@ -2716,7 +2736,11 @@ def get_worktime_statistics(self, project_id: str, **kwargs) -> Tuple[Any, reque
27162736
27172737
27182738
"""
2719-
warnings.warn("deprecated", FutureWarning)
2739+
warnings.warn(
2740+
"annofabapi.AnnofabApi.get_worktime_statistics() is deprecated and will be removed.",
2741+
FutureWarning,
2742+
stacklevel=2,
2743+
)
27202744
url_path = f"/projects/{project_id}/statistics/worktimes"
27212745
http_method = "GET"
27222746
keyword_params: Dict[str, Any] = {}

annofabapi/wrapper.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,11 @@ def download_full_annotation_archive(self, project_id: str, dest_path: str) -> s
265265
ダウンロード元のURL
266266
267267
"""
268-
warnings.warn("deprecated", FutureWarning)
268+
warnings.warn(
269+
"annofabapi.Wrapper.download_full_annotation_archive() is deprecated and will be removed.",
270+
FutureWarning,
271+
stacklevel=2,
272+
)
269273
_, response = self.api.get_archive_full_with_pro_id(project_id)
270274
url = response.headers["Location"]
271275
response2 = _download(url, dest_path)
@@ -1014,7 +1018,9 @@ def get_task_statistics(self, project_id: str) -> List[Any]:
10141018
10151019
10161020
"""
1017-
warnings.warn("deprecated", FutureWarning)
1021+
warnings.warn(
1022+
"annofabapi.Wrapper.get_task_statistics() is deprecated and will be removed.", FutureWarning, stacklevel=2
1023+
)
10181024
_, response = self.api.get_task_statistics(project_id)
10191025
result = self._request_location_header_url(response)
10201026
if result is not None:
@@ -1034,7 +1040,11 @@ def get_account_statistics(self, project_id: str) -> List[Any]:
10341040
Returns:
10351041
10361042
"""
1037-
warnings.warn("deprecated", FutureWarning)
1043+
warnings.warn(
1044+
"annofabapi.Wrapper.get_account_statistics() is deprecated and will be removed.",
1045+
FutureWarning,
1046+
stacklevel=2,
1047+
)
10381048
_, response = self.api.get_account_statistics(project_id)
10391049
result = self._request_location_header_url(response)
10401050
if result is not None:
@@ -1054,7 +1064,11 @@ def get_inspection_statistics(self, project_id: str) -> List[Any]:
10541064
Returns:
10551065
10561066
"""
1057-
warnings.warn("deprecated", FutureWarning)
1067+
warnings.warn(
1068+
"annofabapi.Wrapper.get_inspection_statistics() is deprecated and will be removed.",
1069+
FutureWarning,
1070+
stacklevel=2,
1071+
)
10581072
_, response = self.api.get_inspection_statistics(project_id)
10591073
result = self._request_location_header_url(response)
10601074
if result is not None:
@@ -1074,7 +1088,11 @@ def get_task_phase_statistics(self, project_id: str) -> List[Any]:
10741088
Returns:
10751089
10761090
"""
1077-
warnings.warn("deprecated", FutureWarning)
1091+
warnings.warn(
1092+
"annofabapi.Wrapper.get_task_phase_statistics() is deprecated and will be removed.",
1093+
FutureWarning,
1094+
stacklevel=2,
1095+
)
10781096
_, response = self.api.get_task_phase_statistics(project_id)
10791097
result = self._request_location_header_url(response)
10801098
if result is not None:
@@ -1113,7 +1131,11 @@ def get_worktime_statistics(self, project_id: str) -> List[Any]:
11131131
タスク作業時間集計
11141132
11151133
"""
1116-
warnings.warn("deprecated", FutureWarning)
1134+
warnings.warn(
1135+
"annofabapi.Wrapper.get_worktime_statistics() is deprecated and will be removed.",
1136+
FutureWarning,
1137+
stacklevel=2,
1138+
)
11171139
_, response = self.api.get_worktime_statistics(project_id)
11181140
result = self._request_location_header_url(response)
11191141
if result is not None:
@@ -2394,7 +2416,11 @@ def get_labor_control_worktime(
23942416
* plan_worktime:予定作業時間[hour]
23952417
* working_description:実績に関するコメント(optional)
23962418
"""
2397-
warnings.warn("deprecated", FutureWarning)
2419+
warnings.warn(
2420+
"annofabapi.Wrapper.get_labor_control_worktime() is deprecated and will be removed.",
2421+
FutureWarning,
2422+
stacklevel=2,
2423+
)
23982424

23992425
def _to_new_data(labor: Dict[str, Any]) -> Dict[str, Any]:
24002426
labor["actual_worktime"] = self._get_actual_worktime_hour_from_labor(labor)
@@ -2474,7 +2500,11 @@ def get_labor_control_availability(
24742500
* date
24752501
* availability:予定稼働時間[hour]
24762502
"""
2477-
warnings.warn("deprecated", FutureWarning)
2503+
warnings.warn(
2504+
"annofabapi.Wrapper.get_labor_control_availability() is deprecated and will be removed.",
2505+
FutureWarning,
2506+
stacklevel=2,
2507+
)
24782508

24792509
def _to_new_data(labor: Dict[str, Any]) -> Dict[str, Any]:
24802510
labor["availability"] = self._get_plan_worktime_hour_from_labor(labor)

generate/template/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
"""
5454
{{#isDeprecated}}
55-
warnings.warn("deprecated", FutureWarning)
55+
warnings.warn("annofabapi.AnnofabApi.{{operationId}}() is deprecated and will be removed.", FutureWarning, stacklevel=2)
5656
{{/isDeprecated}}
5757
url_path = f'{{{path}}}'
5858
http_method = '{{httpMethod}}'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "annofabapi"
3-
version = "0.50.1"
3+
version = "0.50.2"
44
description = "Python Clinet Library of AnnoFab WebAPI (https://annofab.com/docs/api/)"
55
authors = ["yuji38kwmt"]
66
license = "MIT"

0 commit comments

Comments
 (0)