Skip to content

Commit

Permalink
fix: attr-defined error
Browse files Browse the repository at this point in the history
  • Loading branch information
ngshiheng committed Dec 21, 2023
1 parent abdde6c commit e554b31
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions burplist/pipelines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from itemadapter import ItemAdapter
from itemadapter.adapter import ItemAdapter
from scrapy import Spider
from scrapy.exceptions import DropItem
from sqlalchemy.exc import ProgrammingError
Expand Down Expand Up @@ -86,7 +86,10 @@ def process_item(self, item: ProductItem, spider: Spider) -> ProductItem:
existing_product = session.query(Product).filter_by(url=url, quantity=quantity).one_or_none()

except ProgrammingError as exception:
spider.logger.exception("An unexpected error has occurred.", extra=dict(exception=exception, url=url, quantity=quantity))
spider.logger.exception(
"An unexpected error has occurred.",
extra=dict(exception=exception, url=url, quantity=quantity),
)
raise DropItem(f"Dropping item <{url}> due to unexpected error.") from exception

finally:
Expand Down

0 comments on commit e554b31

Please sign in to comment.