From 9016a7b613e4d02164ac9b564c7eea6108900d6f Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Wed, 17 Jul 2024 21:41:08 +0500 Subject: [PATCH] Improve DynamicDeps docs. --- docs/dynamic-deps.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/dynamic-deps.rst b/docs/dynamic-deps.rst index 242246d8..529cf9f1 100644 --- a/docs/dynamic-deps.rst +++ b/docs/dynamic-deps.rst @@ -46,9 +46,15 @@ request meta dictionary using the "inject" key: def parse_book(self, response, book_page: BookPage, dynamic: DynamicDeps): + # access the dynamic dependency values by their type: other_dep = dynamic[OtherDep] ... + # or get them and their types at the run time: + for dep_type, dep in dynamic.items(): + if dep_type is OtherDep: + ... The types passed this way are used in the dependency resolution as usual, with the created instances available in the :class:`scrapy_poet.DynamicDeps -` instance. +` instance, which is a dictionary with +dependency types as keys and their instances as values.