-
Notifications
You must be signed in to change notification settings - Fork 555
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
BREAKING CHANGE: Make Literal more standards compliant #2460
base: main
Are you sure you want to change the base?
BREAKING CHANGE: Make Literal more standards compliant #2460
Conversation
d051727
to
078a117
Compare
Raise an error when nested graphs occur in TriG. With this change, the <http://www.w3.org/2013/TriGTests/#trig-graph-bad-07> test passes. --------- Co-authored-by: WhiteGobo <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Iwan Aucamp <[email protected]>
Skip the following tests that rely on SPARQL 1.0 grammar and are incompatible with the SPARQL 1.1 grammar: - <http://www.w3.org/2001/sw/DataAccess/tests/data-r2/basic/manifest#term-6> - <http://www.w3.org/2001/sw/DataAccess/tests/data-r2/basic/manifest#term-7> --------- Co-authored-by: WhiteGobo <[email protected]> Co-authored-by: Iwan Aucamp <[email protected]>
TBD checkpoint aucampia/20230609T2355-literal_datatype: checkpoint 20230817T000443
078a117
to
376c034
Compare
if lang is not None or datatype == _RDF_LANGSTRING: | ||
if lang is None: | ||
raise ValueError(f"language cannot be None if datatype is {datatype}") | ||
if not lang: | ||
raise ValueError("language cannot be empty string") | ||
if not _lang_tag_regex.match(lang): | ||
raise ValueError( | ||
"language tag must match the pattern " | ||
"^[a-zA-Z]+(?:-[a-zA-Z0-9]+)*$ " | ||
f"but was {lang}" | ||
) | ||
|
||
if datatype is None: | ||
datatype = _RDF_LANGSTRING | ||
|
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.
Let q=Literal("ex", datatype=something)
. This will also overwrite any datatype given to a new Literal Literal(q, lang="en")
.
#prevous:
Literal(q, lang="en")
# >> Literal("ex", lang="en", datatype=something)
# now:
Literal(q, lang="en")
# >> Literal("ex", lang="en", datatype=RDF.langString)
Before the datatype was inherited. But i havent seen this behaviour documented, so there was no expected behaviour before. But we could mention this change in behaviour nonetheless.
Also this will handle issue #2603
_XSD_PFX = "http://www.w3.org/2001/XMLSchema#" | ||
_RDF_PFX = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
|
||
_RDF_LANGSTRING = URIRef(_RDF_PFX + "langString") |
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.
It might be more useful to make _RDF_LANGSTRING
a class attribute for Literal. Then someone can change the default datatype for langstring by using a childclass instead of changing it programwide.
But im not sure
@WhiteGobo @aucampia are either of you likely to be able to update / improve this PR? |
I'd like to see this merged after the release of v7.1.0, along with this related change #2866 as part of the "lots of breaking changes" release that RDFLib-8 will be. |
be
None
.to
rdf:langString
.Related issues:
None
andXSD.string
#2123