Skip to content

Commit 76fac9d

Browse files
committed
Update Index.create(...) method as @classmethod
1 parent fb8c217 commit 76fac9d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

meilisearch/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def create_index(self, uid, options=None):
4545
HTTPError
4646
In case of any other error found here https://docs.meilisearch.com/references/#errors-status-code
4747
"""
48-
index_dict = Index.create(self.config, uid, options)
49-
return Index(self.config, index_dict['uid'], index_dict['primaryKey'])
48+
return Index.create(self.config, uid, options)
5049

5150
def get_indexes(self):
5251
"""Get all indexes.

meilisearch/index.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def get_primary_key(self):
8888
"""
8989
return self.fetch_info().primary_key
9090

91-
@staticmethod
92-
def create(config, uid, options=None):
91+
@classmethod
92+
def create(cls, config, uid, options=None):
9393
"""Create the index.
9494
9595
Parameters
@@ -111,7 +111,8 @@ def create(config, uid, options=None):
111111
if options is None:
112112
options = {}
113113
payload = {**options, 'uid': uid}
114-
return HttpRequests(config).post(config.paths.index, payload)
114+
index_dict = HttpRequests(config).post(config.paths.index, payload)
115+
return cls(config, index_dict['uid'], index_dict['primaryKey'])
115116

116117
@staticmethod
117118
def list_all(config):

0 commit comments

Comments
 (0)