Skip to content

Commit 94cbb30

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent 98142f5 commit 94cbb30

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

dataikuapi/dss/project.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ def duplicate(self, target_project_key,
193193
if target_project_folder is not None:
194194
obj["targetProjectFolderId"] = target_project_folder.project_folder_id
195195

196-
ref = self.client._perform_json("POST", "/projects/%s/duplicate/" % self.project_key, body = obj)
197-
return ref
196+
return self.client._perform_json(
197+
"POST", "/projects/%s/duplicate/" % self.project_key, body=obj
198+
)
198199

199200
########################################################
200201
# Project infos
@@ -286,9 +287,9 @@ def list_datasets(self, as_type="listitems"):
286287
:rtype: list
287288
"""
288289
items = self.client._perform_json("GET", "/projects/%s/datasets/" % self.project_key)
289-
if as_type == "listitems" or as_type == "listitem":
290+
if as_type in ["listitems", "listitem"]:
290291
return [DSSDatasetListItem(self.client, item) for item in items]
291-
elif as_type == "objects" or as_type == "object":
292+
elif as_type in ["objects", "object"]:
292293
return [DSSDataset(self.client, self.project_key, item["name"]) for item in items]
293294
else:
294295
raise ValueError("Unknown as_type")
@@ -426,9 +427,9 @@ def list_streaming_endpoints(self, as_type="listitems"):
426427
:rtype: list
427428
"""
428429
items = self.client._perform_json("GET", "/projects/%s/streamingendpoints/" % self.project_key)
429-
if as_type == "listitems" or as_type == "listitem":
430+
if as_type in ["listitems", "listitem"]:
430431
return [DSSStreamingEndpointListItem(self.client, item) for item in items]
431-
elif as_type == "objects" or as_type == "object":
432+
elif as_type in ["objects", "object"]:
432433
return [DSSStreamingEndpoint(self.client, self.project_key, item["id"]) for item in items]
433434
else:
434435
raise ValueError("Unknown as_type")
@@ -738,7 +739,7 @@ def list_model_evaluation_stores(self, as_type=None):
738739
:rtype: list
739740
"""
740741
items = self.client._perform_json("GET", "/projects/%s/modelevaluationstores/" % self.project_key)
741-
if as_type == "objects" or as_type == "object":
742+
if as_type in ["objects", "object"]:
742743
return [DSSModelEvaluationStore(self.client, self.project_key, item["id"]) for item in items]
743744
else:
744745
return items
@@ -949,9 +950,9 @@ def set_variables(self, obj):
949950
950951
@param dict obj: must be a modified version of the object returned by get_variables
951952
"""
952-
if not "standard" in obj:
953+
if "standard" not in obj:
953954
raise ValueError("Missing 'standard' key in argument")
954-
if not "local" in obj:
955+
if "local" not in obj:
955956
raise ValueError("Missing 'local' key in argument")
956957

957958
self.client._perform_empty(
@@ -1168,9 +1169,9 @@ def list_recipes(self, as_type="listitems"):
11681169
:rtype: list
11691170
"""
11701171
items = self.client._perform_json("GET", "/projects/%s/recipes/" % self.project_key)
1171-
if as_type == "listitems" or as_type == "listitem":
1172+
if as_type in ["listitems", "listitem"]:
11721173
return [DSSRecipeListItem(self.client, item) for item in items]
1173-
elif as_type == "objects" or as_type == "object":
1174+
elif as_type in ["objects", "object"]:
11741175
return [DSSRecipe(self.client, self.project_key, item["name"]) for item in items]
11751176
else:
11761177
raise ValueError("Unknown as_type")
@@ -1256,7 +1257,7 @@ def new_recipe(self, type, name=None):
12561257
return recipe.SamplingRecipeCreator(name, self)
12571258
elif type == "split":
12581259
return recipe.SplitRecipeCreator(name, self)
1259-
elif type == "prepare" or type == "shaker":
1260+
elif type in ["prepare", "shaker"]:
12601261
return recipe.PrepareRecipeCreator(name, self)
12611262
elif type == "prediction_scoring":
12621263
return recipe.PredictionScoringRecipeCreator(name, self)
@@ -1614,11 +1615,9 @@ def add_exposed_object(self, object_type, object_id, target_project):
16141615
found_eo = {"type" : object_type, "localName" : object_id, "rules" : []}
16151616
self.settings["exposedObjects"]["objects"].append(found_eo)
16161617

1617-
already_exists = False
1618-
for rule in found_eo["rules"]:
1619-
if rule["targetProject"] == target_project:
1620-
already_exists = True
1621-
break
1618+
already_exists = any(
1619+
rule["targetProject"] == target_project for rule in found_eo["rules"]
1620+
)
16221621

16231622
if not already_exists:
16241623
found_eo["rules"].append({"targetProject": target_project})

0 commit comments

Comments
 (0)