RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.17k stars 555 forks source link

Python interactive session help(rdflib) raises long list of warnings #1972

Open ajnelson-nist opened 2 years ago

ajnelson-nist commented 2 years ago

I tried, using today's master branch (a3a46114), to view the help menu after installing rdflib into a fresh virtual environment. I was quickly overrun with warnings, such as:

[...snip...]
https://brickschema.org/schema/Brick#AED =  does not look like a valid URI, trying to serialize this will break.
https://brickschema.org/schema/Brick#AED = rdflib.term.URIRef('https://brickschema.org/schema/Brick#https://brickschema.org/schema/Brick#AED') does not look like a valid URI, trying to serialize this will break.
https://brickschema.org/schema/Brick#AHU =  does not look like a valid URI, trying to serialize this will break.
https://brickschema.org/schema/Brick#AHU = rdflib.term.URIRef('https://brickschema.org/schema/Brick#https://brickschema.org/schema/Brick#AHU') does not look like a valid URI, trying to serialize this will break.
[...snip...]
http://www.w3.org/2001/XMLSchema#totalDigits =  does not look like a valid URI, trying to serialize this will break.
http://www.w3.org/2001/XMLSchema#totalDigits = rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#http://www.w3.org/2001/XMLSchema#totalDigits') does not look like a valid URI, trying to serialize this will break.
[...snip...]

Steps to reproduce:

  1. Install rdflib into a virtual environment.
  2. Open Python interactive session.
  3. import rdflib
  4. help(rdflib)
aucampia commented 2 years ago

But are they valid URIs? It is possible to disable logging per logger, and I think their is some hierarchical behavior here, so it should not be that difficult to disable these warnings. I'm busy with work on our test suite and actually conformance with the test suite requires us not parsing invalid URIs at all, so we are already more lenient than we should be, I think warnings for invalid URIs are reasonable.

aucampia commented 2 years ago

oh wait, I think I completely missed your point :D - this should indeed be addressed.

ajnelson-nist commented 2 years ago

No worries, it took me a second to eyeball the whitespace.

From what I'm seeing, it looks like some generative code is being misparsed. The snippet https://brickschema.org/schema/Brick#AED = does not look like a valid URI looks a bit like what's being parsed as an IRI is https://brickschema.org/schema/Brick#AED =.

aucampia commented 2 years ago

One line to reproduce:

pipx run --spec git+https://github.com/RDFLib/rdflib.git@master#egg=rdflib python -c 'import rdflib; help(rdflib)'
StroemPhi commented 1 year ago

We have the same issue. Can you maybe tell me about the status of the related PR?