Closed stschiff closed 4 years ago
@stschiff do you want to take a stab at adding tests as well, or should I do?
Ah right. Of course. Will do! And I will leave that topic branch open for now anyway, perhaps there'll be more types.
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.
@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
}
}
Merging #35 into master will increase coverage by
0.00%
. The diff coverage is100.00%
.
@@ 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 I just remembered why I didn't implement
nonNegativeInteger
.csvw.metadata.Datatype
already has an attributeminimum
which when used together withinteger
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.
Yes, I think we should support as many as possible, in particular if its not much work (o the work is already done :) ).
I'm not a big fan of topic branches, though, or any other kind of long-lived branch - so I'll merge now :)
just added this one new datatype, perhaps more to come if need be.