Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from ItemProvider to custom builders. #175

Merged
merged 13 commits into from
Dec 26, 2023
Merged

Conversation

wRAR
Copy link
Member

@wRAR wRAR commented Dec 1, 2023

Needs scrapinghub/andi#27

TODO:

  • Bump the minimum andi version.
  • Check the xfail tests.
  • Fix/discuss test_page_object_returning_item_which_is_also_a_dep_2().
  • Remove prev_instances code?

@wRAR
Copy link
Member Author

wRAR commented Dec 1, 2023

Regarding test_page_object_returning_item_which_is_also_a_dep_2() (https://github.com/scrapinghub/scrapy-poet/blob/master/tests/test_web_poet_rules.py#L1591): the first and the third expectations pass but the second one doesn't, because both page objects are called. This is probably a bug but I didn't investigate it yet.

@wRAR
Copy link
Member Author

wRAR commented Dec 1, 2023

Regarding prev_instances: it was added just for ItemProvider, and it's likely that we won't need it in the future, but I'm not sure if we should remove it now.

@Gallaecio
Copy link
Member

Reading the examples now, I see that the scenario I originally mentioned is not meant to be supported, what we support is a page object to have a provided item as a dependency, not an item from a different page object. That makes sense, and makes things simpler 🎉

@wRAR
Copy link
Member Author

wRAR commented Dec 11, 2023

Regarding test_page_object_returning_item_which_is_also_a_dep_2():

In the first assert block we request Kangaroo. It's built from JoeyPage because that one has a higher priority, and JoeyPage is built from an externally provided Kangaroo because andi breaks a Kangaroo<->JoeyPage loop.

But when in the second assert we request KangarooPage it's built from Kangaroo which is built, as in the first block, from JoeyPage, while the test expects it to be built directly.

So if we want to keep the old behavior we need to add some checks to andi and I'm not sure what should they check to know that if KangarooPage is requested its Kangaroo dep should be built directly and not via JoeyPage.

Copy link
Member

@kmike kmike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

codecov bot commented Dec 26, 2023

Codecov Report

Merging #175 (de6105c) into master (4df98a3) will decrease coverage by 0.86%.
Report is 1 commits behind head on master.
The diff coverage is 96.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #175      +/-   ##
==========================================
- Coverage   85.97%   85.11%   -0.86%     
==========================================
  Files          14       14              
  Lines         827      786      -41     
==========================================
- Hits          711      669      -42     
- Misses        116      117       +1     
Files Coverage Δ
scrapy_poet/commands.py 35.29% <100.00%> (ø)
scrapy_poet/downloadermiddlewares.py 100.00% <ø> (ø)
scrapy_poet/injection.py 98.58% <100.00%> (+0.05%) ⬆️
scrapy_poet/page_input_providers.py 98.59% <83.33%> (-1.41%) ⬇️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants