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

added nonNegativeInteger #35

Merged
merged 5 commits into from
Apr 21, 2020
Merged

added nonNegativeInteger #35

merged 5 commits into from
Apr 21, 2020

Conversation

stschiff
Copy link
Collaborator

just added this one new datatype, perhaps more to come if need be.

@stschiff stschiff linked an issue Apr 20, 2020 that may be closed by this pull request
@xrotwang
Copy link
Contributor

@stschiff do you want to take a stab at adding tests as well, or should I do?

@stschiff
Copy link
Collaborator Author

Ah right. Of course. Will do! And I will leave that topic branch open for now anyway, perhaps there'll be more types.

@stschiff
Copy link
Collaborator Author

OK, I've fixed the test, but it's not clear to me whether it's correct what I'm doing here. I'm currently raising a ValueError when parsing, but you seem to be separating parsing from validating.

@xrotwang
Copy link
Contributor

@stschiff I just remembered why I didn't implement nonNegativeInteger. csvw.metadata.Datatype already has an attribute minimum which when used together with integer will provide what you want:

{
    "name": "...",
    "datatype": {
        "base": "integer",
        "minimum": 0
    }
}

@codecov-io
Copy link

codecov-io commented Apr 20, 2020

Codecov Report

Merging #35 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #35   +/-   ##
=======================================
  Coverage   99.90%   99.90%           
=======================================
  Files          15       15           
  Lines        2211     2222   +11     
=======================================
+ Hits         2209     2220   +11     
  Misses          2        2           
Impacted Files Coverage Δ
src/csvw/datatypes.py 100.00% <100.00%> (ø)
tests/test_datatypes.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 f943480...8775561. Read the comment docs.

@stschiff
Copy link
Collaborator Author

@stschiff I just remembered why I didn't implement nonNegativeInteger. csvw.metadata.Datatype already has an attribute minimum which when used together with integer will provide what you want.

Yes, that makes sense, I also realised as much. I'm open to doing it this way, it would require some minor changes in my schemas, but nothing dramatic. Up to you. The official csvw standard has all these edge-case datatypes, in principle, so perhaps it's good to support them even if they're somewhat redundant.

@xrotwang
Copy link
Contributor

Yes, I think we should support as many as possible, in particular if its not much work (o the work is already done :) ).

@xrotwang
Copy link
Contributor

I'm not a big fan of topic branches, though, or any other kind of long-lived branch - so I'll merge now :)

@xrotwang xrotwang merged commit af7d40b into master Apr 21, 2020
@xrotwang xrotwang deleted the new_datatypes branch April 21, 2020 11:52
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.

Adding more datatypes
3 participants