From 73b6ce8cb560da71b082efdba44b90e1ea932b17 Mon Sep 17 00:00:00 2001 From: Eugenio Lacuesta Date: Mon, 22 Jun 2020 14:13:37 -0300 Subject: [PATCH] Update docs about dataclass items and loaders --- docs/topics/loaders.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/topics/loaders.rst b/docs/topics/loaders.rst index c5f121dbf..e921395d2 100644 --- a/docs/topics/loaders.rst +++ b/docs/topics/loaders.rst @@ -84,9 +84,11 @@ Working with dataclass items By default, :ref:`dataclass items ` require all fields to be passed when created. This could be an issue when using dataclass items with -item loaders, since fields could be populated incrementally. +item loaders: unless a pre-populated item is passed to the loader, fields +will be populated incrementally using the loader's :meth:`~ItemLoader.add_xpath`, +:meth:`~ItemLoader.add_css` and :meth:`~ItemLoader.add_value` methods. -Given the way that item loaders store data internally, the recommended approach +Given the way that item loaders store data internally, one approach to overcome this is to define items using the :func:`~dataclasses.field` function, with ``list`` as the ``default_factory`` argument::