Skip to content

Commit e35b691

Browse files
committed
deprecate 'increment_progress' and 'update_progress'
1 parent fc2ab2b commit e35b691

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "taskbadger"
3-
version = "1.6.0"
3+
version = "1.6.1"
44
description = "The official Python SDK for Task Badger"
55
requires-python = ">=3.9"
66
authors = []

taskbadger/sdk.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
22
import logging
33
import os
4+
import warnings
45
from typing import Any
56

67
from taskbadger.exceptions import (
@@ -328,6 +329,14 @@ def update_status(self, status: StatusEnum):
328329
self.update(status=status)
329330

330331
def increment_progress(self, amount: int):
332+
warnings.warn(
333+
"'task.increment_progress' will be removed in v1.7.0. Use 'task.increment_value' instead.",
334+
DeprecationWarning,
335+
stacklevel=2,
336+
)
337+
return self.increment_value(amount)
338+
339+
def increment_value(self, amount: int):
331340
"""Increment the task progress by adding the specified amount to the current value.
332341
If the task value is not set it will be set to `amount`.
333342
"""
@@ -337,6 +346,14 @@ def increment_progress(self, amount: int):
337346
self.update(value=new_amount)
338347

339348
def update_progress(self, value: int, value_step: int = None, rate_limit: int = None):
349+
warnings.warn(
350+
"'task.update_progress' will be removed in v1.7.0. Use 'task.update_value' instead.",
351+
DeprecationWarning,
352+
stacklevel=2,
353+
)
354+
self.update_value(value, value_step, rate_limit)
355+
356+
def update_value(self, value: int, value_step: int = None, rate_limit: int = None):
340357
"""Update task progress.
341358
342359
Arguments:

tests/test_sdk.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,19 @@ def test_update_data(settings, patched_update):
154154
_verify_update(settings, patched_update, data={"a": 1})
155155

156156

157+
def test_increment_value(settings, patched_update):
158+
api_task = task_for_test()
159+
task = Task(api_task)
160+
161+
patched_update.return_value = Response(HTTPStatus.OK, b"", {}, task_for_test(value=10))
162+
163+
task.increment_value(10)
164+
_verify_update(settings, patched_update, value=10)
165+
166+
task.increment_value(5)
167+
_verify_update(settings, patched_update, value=15)
168+
169+
157170
def test_ping(settings, patched_update):
158171
task = Task(task_for_test())
159172

@@ -179,18 +192,18 @@ def test_update_progress_rate_limit(settings, patched_update):
179192

180193
updated_at = task.updated
181194
patched_update.return_value = Response(HTTPStatus.OK, b"", {}, task_for_test())
182-
task.update_progress(2, rate_limit=1)
195+
task.update_value(2, rate_limit=1)
183196
assert len(patched_update.call_args_list) == 0
184197

185-
task.update_progress(2)
198+
task.update_value(2)
186199
_verify_update(settings, patched_update, value=2)
187200
assert task.updated > updated_at
188201

189-
task.update_progress(3, rate_limit=1)
202+
task.update_value(3, rate_limit=1)
190203
assert len(patched_update.call_args_list) == 1
191204

192205
task._task.updated = task._task.updated - datetime.timedelta(seconds=1)
193-
task.update_progress(3, rate_limit=1)
206+
task.update_value(3, rate_limit=1)
194207
assert len(patched_update.call_args_list) == 2
195208

196209

0 commit comments

Comments
 (0)