From abfdc1b5425997f1aa69b29465c6ab2324f37fd0 Mon Sep 17 00:00:00 2001 From: Eugenio Lacuesta Date: Mon, 11 May 2020 13:20:06 -0300 Subject: [PATCH] Update docstring for Item class --- scrapy/item.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scrapy/item.py b/scrapy/item.py index b9a0acd3d..97dfed976 100644 --- a/scrapy/item.py +++ b/scrapy/item.py @@ -138,18 +138,20 @@ class Item(DictItem, metaclass=ItemMeta): """ Base class for scraped items. - In Scrapy, an object is considered an *item* if it is an instance of either - :class:`Item` or :class:`dict`. For example, when the output of a + In Scrapy, an object is considered an ``item`` if it is an instance of either + :class:`Item` or :class:`dict`, or any subclass. For example, when the output of a spider callback is evaluated, only instances of :class:`Item` or :class:`dict` are passed to :ref:`item pipelines `. If you need instances of a custom class to be considered items by Scrapy, you must inherit from either :class:`Item` or :class:`dict`. - Items offer the ability to declare :class:`Field` attributes, which can be - used to define metadata and control the way data is processed internally. - Please refer to the :ref:`documentation about fields ` - for additional information. + Items must declare :class:`Field` attributes, which are processed and stored + in the ``fields`` attribute. This restricts the set of allowed field names + and prevents typos, raising ``KeyError`` when referring to undefined fields. + Additionally, fields can be used to define metadata and control the way + data is processed internally. Please refer to the :ref:`documentation + about fields ` for additional information. Unlike instances of :class:`dict`, instances of :class:`Item` may be :ref:`tracked ` to debug memory leaks.