Skip to content

Commit

Permalink
Breaking change: Don't extract value from 1-length dict (#399)
Browse files Browse the repository at this point in the history
* dont extract value from dict

* fix test

* fix
  • Loading branch information
mski-iksm authored Sep 29, 2024
1 parent 92f6b0d commit 8bd8fe0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions gokart/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,7 @@ def _load(targets):
return {k: _load(t) for k, t in targets.items()}
return targets.load()

data = _load(self._get_input_targets(target))
if target is None and isinstance(data, dict) and len(data) == 1:
return list(data.values())[0]
return data
return _load(self._get_input_targets(target))

@overload
def load_generator(self, target: Union[None, str, TargetOnKart] = None) -> Generator[Any, None, None]: ...
Expand Down
2 changes: 1 addition & 1 deletion test/test_task_on_kart.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_load_with_single_dict_target(self):

data = task.load()
target.load.assert_called_once()
self.assertEqual(data, 1)
self.assertEqual(data, {'target_key': 1})

def test_load_with_keyword(self):
task = _DummyTask()
Expand Down

0 comments on commit 8bd8fe0

Please sign in to comment.