Skip to content

Commit

Permalink
Improve DynamicDeps docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Jul 17, 2024
1 parent 887e2fe commit 9016a7b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/dynamic-deps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
<scrapy_poet.injection.DynamicDeps>` instance.
<scrapy_poet.injection.DynamicDeps>` instance, which is a dictionary with
dependency types as keys and their instances as values.

0 comments on commit 9016a7b

Please sign in to comment.