Merged
Conversation
Replaces "oneOf" with "anyOf". "oneOf" requires that all the branches are chosen to verify that _only_ one matches, which is expensive and unnecessary in this schema
Use "if" to check the type property of a class before attempting to check it in more detail. This allows classes to be quickly discarded by the schema validators. It appears that some validators struggle with bailing out of "allOf" early (in particular, the python jsonschema validator), so explicitly adding this check yields large parsing benefits. Do the same for the top level decision between multiple objects (with an "@graph" property) or a single object. In testing, this change yielded a 90% reduction in validation time with the python jsonschema implementation
Owner
Author
|
@bact pyrefly is causing some heartburn here; if you don't have any ideas I might disable it. It appears it's actually ignoring the type annotations from |
Collaborator
|
Oh. I will take a look. |
pyrefly distinguishes between functions that have an empty `return` (with a type annotation of `None`) and functions that have no return (with a type annotation of `Never`). Since the child classes override these functions, pyrefly wants these to match so explicitly indicate that the return type is `None`.
Newer versions of pyrefly appear to be overly pedantic and ignore the type annotations of functions, preferring to inspect the code for the actual return types. This breaks rdflib since it frequently has different type annotations from what functions might actually return (for example, `rdflib.terms.URIRef`). Since we can't think of a good work around for this, mark the tests as expected to fail for now.
431cbb4 to
d803b05
Compare
Collaborator
|
Trying to look around, it looks like Rdflib treated URIRef as "str-like" during runtime, and that makes pyrefly unhappy. Tried to put this from typing import Any
class Node:
...
class IdentifiedNode(Node):
...
class URIRef(IdentifiedNode, str):
def toPython(self) -> str: ...
class BNode(Node):
def n3(self) -> str: ...
class Literal(Node):
def toPython(self) -> Any: ...I think it's fine to put the pyrefly test as xfail for now. |
bact
approved these changes
Nov 6, 2025
goneall
added a commit
to spdx/tools-java
that referenced
this pull request
Nov 7, 2025
Reference: JPEWdev/shacl2code#56 Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
goneall
added a commit
to spdx/tools-java
that referenced
this pull request
Nov 20, 2025
Reference: JPEWdev/shacl2code#56 Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
goneall
added a commit
to spdx/tools-java
that referenced
this pull request
Nov 22, 2025
Reference: JPEWdev/shacl2code#56 Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a few optimization to the JSON schema to enable to validate faster. This can yield up to a 90% reduction in validation time, depending on the validator