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

Add default return values for attributes #633

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Conversation

MaxDall
Copy link
Collaborator

@MaxDall MaxDall commented Oct 15, 2024

There was a long-lasting bug when using suppress as error handling, disabling its functionality. Because of the lack of default values for Attributes, whenever an error occurred during the parsing of a specific attribute the exception was passed to the scraper, skipping the entire article.

This PR adds a property __default__ to the attribute. The property returns a default value for the specific attribute based on its annotation, thus enabling us to use default values in case of an exception.

Further, I changed the type of body in the guidelines to Optional[ArticleBody] to be more in tune with Article.

The only review-relevant file here is base_parser.py

@MaxDall MaxDall requested a review from addie9800 October 15, 2024 15:52
Copy link
Collaborator

@addie9800 addie9800 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this 👍

@MaxDall MaxDall merged commit 001703e into master Oct 16, 2024
5 checks passed
@MaxDall MaxDall deleted the add-attribute-defaults branch October 16, 2024 13:02
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