scrapinghub / scrapy-poet

Page Object pattern for Scrapy
BSD 3-Clause "New" or "Revised" License
119 stars 28 forks source link

AttributeError: 'str' object has no attribute 'instead_of' #124

Closed kishan3 closed 1 year ago

kishan3 commented 1 year ago

Hello Guys, Recently we updated from v 0.2.0 -> 0.5.0 and we get the below error:

File "/app/python/lib/python3.10/site-packages/scrapy_poet/overrides.py", line 89, in from_crawler
    return cls(crawler.settings.getlist("SCRAPY_POET_OVERRIDES", []))
  File "/app/python/lib/python3.10/site-packages/scrapy_poet/[overrides.py](http://overrides.py/)", line 95, in __init__
    self.add_rule(rule)
  File "/app/python/lib/python3.10/site-packages/scrapy_poet/[overrides.py](http://overrides.py/)", line 111, in add_rule
    self.matcher[rule.instead_of].add_or_update(
AttributeError: 'str' object has no attribute 'instead_of'

Has something changed for providing SCRAPY_POET_OVERRIDES? Currently we provide it in custom_settings

custom_settings = {
        "SCRAPY_POET_OVERRIDES": {
            "amazon.fr": {
                AmazonProductListPage: AmazonFRProductListPage,
                AmazonProductPage: AmazonFRProductPage,
            }
        }
    }
wRAR commented 1 year ago

It was a breaking change in 0.4.0, see the 0.5.0 docs for the 0.5.0 format: https://github.com/scrapinghub/scrapy-poet/blob/0.5.0/docs/overrides.rst

Note that SCRAPY_POET_OVERRIDES will be replaced by SCRAPY_POET_RULES in the next version.

kishan3 commented 1 year ago

Thanks @wRAR!! I think we can close this issue.