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 settings validation #797

Merged
merged 6 commits into from Oct 27, 2020

Conversation

noviluni
Copy link
Collaborator

@noviluni noviluni commented Sep 25, 2020

Adding settings validation in one single place. In that way, we can raise an error if there is misconfigurations and we ensure that the submitted settings are valid.

for: #796

It's not fully finished, as we need a way to get a list of the existing parsers.

I would prefer to get the "existing parsers" from another place (#798), but I think this can be refactored in the future.

@codecov
Copy link

codecov bot commented Sep 25, 2020

Codecov Report

Merging #797 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #797      +/-   ##
==========================================
+ Coverage   98.22%   98.24%   +0.02%     
==========================================
  Files         231      231              
  Lines        2533     2569      +36     
==========================================
+ Hits         2488     2524      +36     
  Misses         45       45              
Impacted Files Coverage Δ
dateparser/conf.py 100.00% <100.00%> (ø)
dateparser/date.py 99.57% <100.00%> (-0.01%) ⬇️
dateparser/parser.py 98.99% <100.00%> (ø)
dateparser/freshness_date_parser.py 98.07% <0.00%> (+0.05%) ⬆️

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 b5e9bec...9a537a4. Read the comment docs.

@noviluni noviluni mentioned this pull request Sep 25, 2020
4 tasks
@noviluni noviluni added this to the v1.0.0 milestone Sep 25, 2020
@noviluni noviluni marked this pull request as ready for review September 28, 2020 08:39

def _check_require_part(provided_list):
"""Returns `True` if the provided list of parts is valid"""
return not set(provided_list) - {'day', 'month', 'year'}
Copy link
Collaborator Author

@noviluni noviluni Sep 29, 2020

Choose a reason for hiding this comment

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

should I check the length to avoid duplicated values?

Copy link
Member

Choose a reason for hiding this comment

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

I think that would be great.


def _check_require_part(provided_list):
"""Returns `True` if the provided list of parts is valid"""
return not set(provided_list) - {'day', 'month', 'year'}
Copy link
Member

Choose a reason for hiding this comment

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

I think that would be great.

dateparser/conf.py Outdated Show resolved Hide resolved
dateparser/conf.py Outdated Show resolved Hide resolved
dateparser/conf.py Outdated Show resolved Hide resolved
dateparser/conf.py Outdated Show resolved Hide resolved
@noviluni
Copy link
Collaborator Author

noviluni commented Oct 26, 2020

Hi @Gallaecio , I addressed all of your feedback, could you review it again?

Thank you!

@noviluni noviluni closed this Oct 26, 2020
@noviluni noviluni reopened this Oct 26, 2020
@noviluni
Copy link
Collaborator Author

Note that this new behaviour will be documented in this PR: #722

@noviluni noviluni merged commit 2908d21 into scrapinghub:master Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants