Skip to content

Commit

Permalink
Fix adding set object to itemloader
Browse files Browse the repository at this point in the history
  • Loading branch information
VMRuiz committed May 14, 2024
1 parent 5fe228a commit 7ccd975
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion itemloaders/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def arg_to_iter(arg: Any) -> Iterable[Any]:
"""
if arg is None:
return []
if isinstance(arg, (list, tuple, Generator)):
if isinstance(arg, (list, tuple, set, Generator)):
return arg
return [arg]

Expand Down
7 changes: 7 additions & 0 deletions tests/test_nested_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class TestItem:
def test_dict(self):
self._test_item({"foo": "bar"})

def test_set(self):
item = {"foo", "bar"}
il = ItemLoader()
il.add_value("item_list", item)

self.assertEqual(il.load_item(), {"item_list": ["foo", "bar"]})

def test_scrapy_item(self):
try:
from scrapy import Field, Item
Expand Down

0 comments on commit 7ccd975

Please sign in to comment.