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

ItemAdapter.is_item_class and ItemAdapter.get_field_meta_from_class #54

Merged
merged 12 commits into from
Aug 26, 2021
Merged

ItemAdapter.is_item_class and ItemAdapter.get_field_meta_from_class #54

merged 12 commits into from
Aug 26, 2021

Conversation

elacuesta
Copy link
Member

@elacuesta elacuesta commented Aug 9, 2021

Bringing in the ability to get field meta data for custom item classes. #53 showed us this is not currently possible without editing library code.

Tasks:

  • Code
  • Tests
  • Docs

@codecov
Copy link

codecov bot commented Aug 9, 2021

Codecov Report

Merging #54 (383a89d) into master (4527d77) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #54   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          248       272   +24     
=========================================
+ Hits           248       272   +24     
Impacted Files Coverage Δ
itemadapter/adapter.py 100.00% <100.00%> (ø)
itemadapter/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4527d77...383a89d. Read the comment docs.

Copy link
Member

@Gallaecio Gallaecio left a comment

Choose a reason for hiding this comment

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

Looking good!

itemadapter/adapter.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Comment on lines 224 to +226
### function `itemadapter.utils.get_field_meta_from_class(item_class: type, field_name: str) -> types.MappingProxyType`

Given an item class and a field name, return a
[`MappingProxyType`](https://docs.python.org/3/library/types.html#types.MappingProxyType)
object, which is a read-only mapping with metadata about the given field. If the item class does not
support field metadata, or there is no metadata for the given field, an empty object is returned.
Alias for `itemadapter.adapter.ItemAdapter.get_field_meta_from_class`
Copy link
Member

Choose a reason for hiding this comment

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

Shall we deprecate (or remove, with the blessing of semantic versioning) this function? (and remove it from the documentation)

Copy link
Member Author

@elacuesta elacuesta Aug 16, 2021

Choose a reason for hiding this comment

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

I'm not sure about removing, as it's used here. We could deprecate, though.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
itemadapter/adapter.py Outdated Show resolved Hide resolved
elacuesta and others added 4 commits August 16, 2021 07:55
Co-authored-by: Adrián Chaves <adrian@chaves.io>
Co-authored-by: Adrián Chaves <adrian@chaves.io>
@elacuesta elacuesta changed the title [WIP] ItemAdapter.is_item_class and ItemAdapter.get_field_meta_from_class ItemAdapter.is_item_class and ItemAdapter.get_field_meta_from_class Aug 18, 2021
@elacuesta elacuesta marked this pull request as ready for review August 18, 2021 15:13
@elacuesta elacuesta merged commit 371838a into scrapy:master Aug 26, 2021
@elacuesta elacuesta deleted the is_item_class branch August 26, 2021 14:03
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.

2 participants