Skip to content

Commit 94e8d5e

Browse files
committed
Make all arguments of Milestone.update() optional
This makes it possible to do something like milestone.update(state='closed') without resetting the title, which seems closer to the purpose of the underlying GitHub API. In addition, previously, milestone.update(title=some_title, state='closed') would error out because the optional parameters were not removed before sending the request.
1 parent 74470ac commit 94e8d5e

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

AUTHORS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ Contributors
5151
- Aleksey Ostapenko (@kbakba)
5252

5353
- Vincent Driessen (@nvie)
54+
55+
- Philip Chimento (@ptomato)

github3/issues/milestone.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ def iter_labels(self, number=-1):
6666
return self._iter(int(number), url, Label)
6767

6868
@requires_auth
69-
def update(self, title, state='', description='', due_on=''):
69+
def update(self, title=None, state=None, description=None, due_on=None):
7070
"""Update this milestone.
7171
72-
state, description, and due_on are optional
72+
All parameters are optional, but it makes no sense to omit all of them
73+
at once.
7374
74-
:param str title: (required), new title of the milestone
75+
:param str title: (optional), new title of the milestone
7576
:param str state: (optional), ('open', 'closed')
7677
:param str description: (optional)
7778
:param str due_on: (optional), ISO 8601 time format:
@@ -80,9 +81,10 @@ def update(self, title, state='', description='', due_on=''):
8081
"""
8182
data = {'title': title, 'state': state,
8283
'description': description, 'due_on': due_on}
84+
self._remove_none(data)
8385
json = None
8486

85-
if title:
87+
if data:
8688
json = self._json(self._patch(self._api, data=dumps(data)), 200)
8789
if json:
8890
self._update_(json)

tests/test_issues.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def test_update(self):
122122
assert self.m.update(None) is False
123123
self.not_called()
124124

125+
assert self.m.update(state='closed')
126+
125127
assert self.m.update('foo', 'closed', ':sparkles:',
126128
'2013-12-31T23:59:59Z')
127129
self.mock_assertions()

0 commit comments

Comments
 (0)