Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hasan7n committed Jul 31, 2023
1 parent 2aa745e commit c23afc7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cli/medperf/comms/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __get_list(
if data["next"] is None:
break

if type(num_elements) == int:
if isinstance(num_elements, int):
return el_list[:num_elements]
return el_list

Expand Down
2 changes: 1 addition & 1 deletion cli/medperf/entities/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def get_default_output(self, task: str, out_key: str, param_key: str = None) ->
return None

out_path = cube["tasks"][task]["parameters"]["outputs"][out_key]
if type(out_path) == dict:
if isinstance(out_path, dict):
# output is specified as a dict with type and default values
out_path = out_path["default"]
cube_loc = str(Path(self.cube_path).parent)
Expand Down
2 changes: 1 addition & 1 deletion cli/medperf/tests/entities/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def set_common_attributes(self, fs, setup, task, out_key, out_value):

# Construct the expected output path
out_val_path = out_value
if type(out_value) == dict:
if isinstance(out_value, dict):
out_val_path = out_value["default"]
self.output = os.path.join(self.cube_path, config.workspace_path, out_val_path)

Expand Down
2 changes: 1 addition & 1 deletion cli/medperf/tests/entities/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_todict_returns_dict_representation(self, Implementation):
ent_dict = ent.todict()

# Assert
assert type(ent_dict) == dict
assert isinstance(ent_dict, dict)

def test_todict_can_recreate_object(self, Implementation):
# Arrange
Expand Down
8 changes: 4 additions & 4 deletions cli/medperf/tests/entities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def setup_benchmark_fs(ents, fs):
bmks_path = storage_path(config.benchmarks_storage)
for ent in ents:
if type(ent) != dict:
if not isinstance(ent, dict):
# Assume we're passing ids
ent = {"id": str(ent)}
id = ent["id"]
Expand Down Expand Up @@ -54,7 +54,7 @@ def setup_benchmark_comms(mocker, comms, all_ents, user_ents, uploaded):
def setup_cube_fs(ents, fs):
cubes_path = storage_path(config.cubes_storage)
for ent in ents:
if type(ent) != dict:
if not isinstance(ent, dict):
# Assume we're passing ids
ent = {"id": str(ent)}
id = ent["id"]
Expand Down Expand Up @@ -127,7 +127,7 @@ def setup_cube_comms_downloads(mocker, fs):
def setup_dset_fs(ents, fs):
dsets_path = storage_path(config.data_storage)
for ent in ents:
if type(ent) != dict:
if not isinstance(ent, dict):
# Assume passing ids
ent = {"id": str(ent)}
id = ent["id"]
Expand Down Expand Up @@ -158,7 +158,7 @@ def setup_dset_comms(mocker, comms, all_ents, user_ents, uploaded):
def setup_result_fs(ents, fs):
results_path = storage_path(config.results_storage)
for ent in ents:
if type(ent) != dict:
if not isinstance(ent, dict):
# Assume passing ids
ent = {"id": str(ent)}
id = ent["id"]
Expand Down
10 changes: 6 additions & 4 deletions cli/medperf/tests/mocks/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ def mock_comms_entity_gets(
get_instance = comms_calls["get_instance"]
upload_instance = comms_calls["upload_instance"]

all_ents = [ent if type(ent) == dict else {"id": ent} for ent in all_ents]
user_ents = [ent if type(ent) == dict else {"id": ent} for ent in user_ents]
all_ents = [ent if isinstance(ent, dict) else {"id": ent} for ent in all_ents]
user_ents = [ent if isinstance(ent, dict) else {"id": ent} for ent in user_ents]

instances = [generate_fn(**ent).dict() for ent in all_ents]
user_instances = [generate_fn(**ent).dict() for ent in user_ents]
mocker.patch.object(comms, get_all, return_value=instances)
mocker.patch.object(comms, get_user, return_value=user_instances)
get_behavior = get_comms_instance_behavior(generate_fn, all_ents)
mocker.patch.object(
comms, get_instance, side_effect=get_behavior,
comms,
get_instance,
side_effect=get_behavior,
)
upload_behavior = upload_comms_instance_behavior(uploaded)
mocker.patch.object(comms, upload_instance, side_effect=upload_behavior)
Expand All @@ -65,7 +67,7 @@ def get_comms_instance_behavior(
function: Function that returns an entity dictionary if found,
or raises an error if not
"""
ids = [ent["id"] if type(ent) == dict else ent for ent in ents]
ids = [ent["id"] if isinstance(ent, dict) else ent for ent in ents]

def get_behavior(id: int):
if id in ids:
Expand Down

0 comments on commit c23afc7

Please sign in to comment.