-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor validation #42
Conversation
Less typing... Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Few comments without having read everything:
|
I like the simplification in the template. I was a bit unsure whether docstring is more intuitive than documentation. For Python developers it is. |
I think the plan looks solid. Are there any portions of the code or any choices you are least sure about and would like input on? |
|
|
About writing the reference dicts by hand - maybe we can write a script that will generate these and break these in controlled ways so that we can generate many dicts in one go for testing? |
UPDATE I fixed this 😄 |
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Fix #33 Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Fixes #34 and makes sure that we report all errors in the template. Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
And uncover a bug... Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Extend test suite somewhat. Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
So long! We test against Python 3.8-dev on Travis Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
77b1b5e
to
c01b439
Compare
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
----- | ||
Complex numbers are a tad more fastidious, as they *might be* read in as | ||
strings. To avoid false negatives, we have a nasty hack, for which RDR will | ||
forever burn in hell. For complex and List[complex] we will re-run type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-) I would have gone for this same solution so may we burn then together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I am convinced the code is better than before so I recommend to merge.
- I think that we will be able to refactor some repetitions but I would do that as follow-up steps later.
- The only change I am unsure about is
docstring
vs.documentation
. Would someone who has never heard ofdocstrings
know what this is? Isdocumentation
more intuitive? Alsodocstrings
are really for documentation extracted out of source code and I am not sure whether the input blueprint counts as source code. But this question of mine should not delay the merge - we can let this question simmer for a while onmaster
until we mint the next release. - I really like the other naming changes and the very careful documentation.
Thank you for this super work!
There seems to be some trouble on Python 3.5 - let me know if I should look into that. |
Fixes behavior of resolve() for Python 3.5 Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
I switched to |
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
This is a refactoring of the validation to fix, or offer a way to fix, #24, #26, #31, #33, and #34.
This is still work-in-progress. I need to do step 7 and make sure that we have a good enough test suite.
I am putting it up early because it might be a bit hard to digest "the festival of
dict
comprehensions". I have tried to document every function I have written in detail. Type hints might be wrong.The general strategy:
a. All keywords have:
* An allowed type.
* A non-empty docstring.
* A default callable that is valid Python, if present.
* Predicates that are valid Python, if present.
Note that the latter two criteria can only be checked later on.
b. No sections are nested under keywords.
c. All sections have a non-empty docstring.
This step might throw.
The fix for #24 is a byproduct of sorts to this restructuring: while traversing recursively if anything throws, we catch it and store how to get to the offending leaf and an appropriate error message.
So for example, when the exception finally throws one will have something like this:
A drawback of this refactoring is that there's now a lot more functions and each of them does a recursive descent in the tree. There is also quite some code duplication: we might get rid of that using more higher-order functions.
TODO
- [ ] Switch toNot neededOrderedDict
throughout, to avoid annoyances with ordering of elements.