Skip to content
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

N3 method for path objects is bugged #2503

Closed
lukasmu opened this issue Jul 30, 2023 · 0 comments · Fixed by #2504
Closed

N3 method for path objects is bugged #2503

lukasmu opened this issue Jul 30, 2023 · 0 comments · Fixed by #2504

Comments

@lukasmu
Copy link
Contributor

lukasmu commented Jul 30, 2023

The n3 method for path objects returns invalid/unexpected paths for non-trivial paths.

Example:

import rdflib
import rdflib.paths

path = rdflib.RDF.type / rdflib.paths.AlternativePath(rdflib.SKOS.note, rdflib.RDFS.comment)

Calling path.n3() here returns <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/<http://www.w3.org/2004/02/skos/core#note>|<http://www.w3.org/2000/01/rdf-schema#comment> (essentially rdf:type/skos:note|rdfs:comment).
However, it the method should rather return <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>/(<http://www.w3.org/2004/02/skos/core#note>|<http://www.w3.org/2000/01/rdf-schema#comment>) (thus rdf:type/(skos:note|rdfs:comment)).

The n3 method ignores all groups as it never introduces any brackets.

Related to #421

lukasmu added a commit to lukasmu/rdflib that referenced this issue Jul 30, 2023
lukasmu added a commit to lukasmu/rdflib that referenced this issue Jul 30, 2023
aucampia pushed a commit that referenced this issue Jul 31, 2023
These path types were formatted without parentheses even if they
contained multiple elements, resulting in string representations that
did not accurately represent the path.

This change fixes the formatting so that the string representations are
enclosed in parentheses when necessary.

- Fixes <#2503>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant