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

python-attrs support to Scrappy Items #2807

Closed
wants to merge 4 commits into from

Conversation

anaisabel7
Copy link

@anaisabel7 anaisabel7 commented Jun 30, 2017

Fixes #2749

Providing new ways to populate Scrapy items and adding the possibility of having @attr.s decorated Scrappy items.

This PR tries to solve the suggestions presented in issue #2749

Certain arguments need to be passed to the decorator in order to make the decorated class (a subclass of Scrapy Item) compatible with the functioning of Scrapy Items. This is covered in the form of tests in the PR.

At the moment, the passing of default values to the attributes of the class (equivalent to Fields in normal Scrapy Items) is covered, but the passing of other metadata, such as validators, has not been considered.

This PR also covers the dot notation access to the Fields in Scrapy Items.

anaisabel7 added 4 commits Jun 23, 2017
…ion. Included corresponding changes in the tests.
…ects with the attr.s decorator can be Scrapy items
…ring the required arguments on the decorator for a consistent behaviour with non-decorated scrapy items.
@codecov-io
Copy link

codecov-io commented Jun 30, 2017

Codecov Report

Merging #2807 into master will increase coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2807      +/-   ##
==========================================
+ Coverage   84.73%   84.75%   +0.01%     
==========================================
  Files         163      163              
  Lines        9164     9175      +11     
  Branches     1362     1367       +5     
==========================================
+ Hits         7765     7776      +11     
  Misses       1147     1147              
  Partials      252      252
Impacted Files Coverage Δ
scrapy/item.py 98.64% <100%> (+0.23%) ⬆️

@kmike
Copy link
Member

kmike commented Jul 15, 2017

Hm, interesting. Your approach makes attribute access work. I was thinking about something a bit different - supporting any class decorated with attr.s, not Item subclasses decorated with attr.s.

@redapple redapple changed the title python-attrs support to Scrappy Items - Issue #2749 python-attrs support to Scrappy Items Jul 18, 2017
@gregbrowndev
Copy link

gregbrowndev commented Aug 16, 2018

Would definitely be interested in support for using attr-based classes. Did you get any further along with this?

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.

4 participants