1365 evaluation order#1366
Conversation
|
Thanks sincerely for giving this a shot! Like I said on the issues, I'd like this done in a more systematic way. Specifically the concerns include:
If you'd like to help, which is very much appreciated, you could review the Dialect v2 label, help by speccing out what a new protocol might look like (I have ideas here clearly but haven't tried to write them out), or help investigate our existing benchmarks and thereby help ensure we're as good or better when we introduce this dependency notion. I'm going to close this as I wouldn't merge it as an incremental change as I said, but again, I do appreciate your work! |
|
(Just because I was giving a list of ways to hopefully constructively focus any help offered -- reviewing unrelated issues is another way to help this move along too, as I have more or less a fixed amount of attention I can spend on the library at this point and so time spent on diagnosing other issues of course takes a decent portion of that attention span up, which delays getting new design work done.) |
|
All good, thanks for the feedback! I'll see about speccing out a new protocol in the next few months, and getting familiar with the related issues. |
Closes #1365
jsonschema/tests/test_validators.py
Adds a test method for the expected behavior, and reverences the issue being solved. The method is slightly longer than others to avoid
TestValidationErrorMessages.message_for, which asserts that there be exactly one error.jsonschema/_keyword.py
The
Keywordclass can define additional tags/behavior for the implementation of the keyword. For now, I have only added a "needs" label, which names other keywords that it cannot be executed before. The name "needs" may be inaccurate, and I'd be happy to change it.The
keyworddecorator makes it trivial to annotate a function to be used as a validator keyword.keywordandKeywordare both optional and completely back-compatible. They would only be necessary for new behavior. There is no change to existing validator function behavior.jsonschema/validators.py
The only changed behavior is that the
iter_errorsevaluatesKeywords after theirneeds. The logic is not as clean as I'd like, but is reasonably straightforward:todokeywords.todo.Keywordthatneedsatodokeyword is labeleddependentand skippeddependentof each other, there is a circular dependency and an error is raised.dependentkeywords are re-attempted.I'd be happy to add comments or a docstring to make the code more self-descriptive if necessary.
📚 Documentation preview 📚: https://python-jsonschema--1366.org.readthedocs.build/en/1366/