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

Improve DateRange validation #627

Merged
merged 4 commits into from
May 17, 2022
Merged

Improve DateRange validation #627

merged 4 commits into from
May 17, 2022

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented May 13, 2022

Noticed that the DateRange parameter was not checking that the value provided is a tuple, which it should be given that DateRange inherits from Tuple.

I've also changed the error message reported when one of the values is not of the correct type:

DateRange parameter 'a' only takes date/datetime values, not type float.

This is slightly different formatting compared to the messages reported by other Parameters, e.g. with a List:

List parameter None must be a list, not an object of type <class 'str'>.

Notice of type float vs. of type <class 'str'>. If the latter is preferred, I could update the error messages of the other Parameters.

@codecov-commenter
Copy link

codecov-commenter commented May 13, 2022

Codecov Report

Merging #627 (75a2130) into master (b38d3b4) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #627      +/-   ##
==========================================
+ Coverage   82.81%   82.82%   +0.01%     
==========================================
  Files           5        5              
  Lines        3037     3039       +2     
==========================================
+ Hits         2515     2517       +2     
  Misses        522      522              
Impacted Files Coverage Δ
numbergen/__init__.py 80.36% <0.00%> (+0.04%) ⬆️

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 b38d3b4...75a2130. Read the comment docs.

@jbednar jbednar added this to the v1.12.2 milestone May 16, 2022
@maximlt
Copy link
Member Author

maximlt commented May 16, 2022

@jlstevens ready for review 🙃

@jlstevens
Copy link
Contributor

Looks good to me!

Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks! I agree that it would be nice to make messages more consistent, but don't have a terribly strong opinion between the ways that type information is printed. I think on balance I'd prefer a simpler, more-English like version (e.g. type float) over a syntax-y version (e.g. <class 'float'>).

@philippjfr
Copy link
Member

Agreed, consistency would be good but for now this is an improvement.

@philippjfr philippjfr merged commit cfa53aa into master May 17, 2022
@philippjfr philippjfr deleted the improve_validate_daterange branch May 17, 2022 21:22
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.

5 participants