Skip to content

Commit e5ed004

Browse files
committed
Make the update() method returns an Index object instead of a dict
1 parent 013f587 commit e5ed004

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

meilisearch/index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ def update(self, **body):
5555
5656
Returns
5757
-------
58-
index: dict
59-
Dictionary containing index information.
58+
index : Index
59+
An Index instance of the newly updated index.
6060
"""
6161
payload = {}
6262
primary_key = body.get('primaryKey', None)
6363
if primary_key is not None:
6464
payload['primaryKey'] = primary_key
6565
response = self.http.put('{}/{}'.format(self.config.paths.index, self.uid), payload)
6666
self.primary_key = response['primaryKey']
67-
return response
67+
return self
6868

6969
def fetch_info(self):
7070
"""Fetch the info of the index.

meilisearch/tests/index/test_index.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def test_update_index(self):
139139
"""Tests updating an index"""
140140
index = self.client.index(uid=self.index_uid)
141141
response = index.update(primaryKey='objectID')
142-
assert isinstance(response, object)
142+
assert response.uid == index.uid
143+
assert response.primary_key == index.primary_key
143144
assert index.primary_key == 'objectID'
144145
assert index.get_primary_key() == 'objectID'
145146

0 commit comments

Comments
 (0)