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

Prevent Collection from adding 'rdf:nil rdf:rest rdf:nil.' triples #2818

Merged
merged 10 commits into from
Jul 30, 2024

Conversation

progval
Copy link
Contributor

@progval progval commented Jul 5, 2024

Summary of changes

Creating 'Collection(graph, RDF.nil)' used to add a 'rdf:nil rdf:rest rdf:nil.' triple to the graph, which turned the empty list into an infinite list.

This was a side-effect of unconditionally appending 'seq' to the collection, which is not possible when the collection is 'nil' without ill side-effects.

This commit makes the append conditional; and also checks the collection is non-empty in case the user explicitly tries to add item to the empty list

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Checked that all tests and type checking passes.
  • If the change has a potential impact on users of this project:
    • Added or updated tests that fail without the change.
    • Updated relevant documentation to avoid inaccuracies.
    • Considered adding additional documentation.
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

Creating 'Collection(graph, RDF.nil)' used to add a 'rdf:nil rdf:rest rdf:nil.'
triple to the graph, which turned the empty list into an infinite list.

This was a side-effect of unconditionally appending 'seq' to the collection,
which is not possible when the collection is 'nil' without ill side-effects.

This commit makes the append conditional; and also checks the collection
is non-empty in case the user explicitly tries to add item to the empty list.
@progval progval changed the title fix: Prevent Collection from add 'rdf:nil rdf:rest rdf:nil.' triples fix: Prevent Collection from adding 'rdf:nil rdf:rest rdf:nil.' triples Jul 15, 2024
rdflib/collection.py Outdated Show resolved Hide resolved
This will allow using _end() in other methods that would not need to append
rdflib/collection.py Outdated Show resolved Hide resolved
@nicholascar nicholascar added the fix Fixes an issue label Jul 24, 2024
@nicholascar nicholascar changed the title fix: Prevent Collection from adding 'rdf:nil rdf:rest rdf:nil.' triples Prevent Collection from adding 'rdf:nil rdf:rest rdf:nil.' triples Jul 24, 2024
@nicholascar nicholascar added the awaiting feedback More feedback is needed from the author of the PR or Issue. label Jul 24, 2024
@coveralls
Copy link

coveralls commented Jul 25, 2024

Coverage Status

coverage: 90.635%. first build
when pulling 6e65136 on progval:collection-empty-list
into 46695eb on RDFLib:main.

rdflib/collection.py Outdated Show resolved Hide resolved
@nicholascar nicholascar removed the awaiting feedback More feedback is needed from the author of the PR or Issue. label Jul 26, 2024
@ashleysommer ashleysommer mentioned this pull request Jul 27, 2024
3 tasks
@ashleysommer
Copy link
Contributor

There's an odd failing test now, weirdly its the same SPARQL test that is failing in #2796 that is completely unrelated to this PR.

@ashleysommer
Copy link
Contributor

That sporadic test is no longer failing, this can merge.

@ashleysommer ashleysommer merged commit cb2c8d1 into RDFLib:main Jul 30, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants