lambdamusic / Ontospy

Python library and command-line interface for inspecting and visualizing RDF models aka ontologies.
http://lambdamusic.github.io/Ontospy/
MIT License
219 stars 52 forks source link

testsuite failure: TypeError: object of type 'bool' has no len() #105

Closed jonassmedegaard closed 2 years ago

jonassmedegaard commented 2 years ago

ontospy 1.9.9.2 fails to build on Debian:

ERROR: test1_load_locally (__main__.TestLoadOntologies)
Check if the ontologies in /RDF folder load ok
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/ontospy/tests/test_load_local.py", line 46, in test1_load_locally
    c.describe()
  File "/<<PKGBUILDDIR>>/ontospy/core/entities.py", line 387, in describe
    self.printStats()
  File "/<<PKGBUILDDIR>>/ontospy/core/entities.py", line 377, in printStats
    printInfo("Instances....: %d" % self.count())
  File "/<<PKGBUILDDIR>>/ontospy/core/entities.py", line 366, in count
    return len(self.instances)
TypeError: object of type 'bool' has no len()

Full build log is at https://buildd.debian.org/status/fetch.php?pkg=ontospy&arch=all&ver=1.9.9.2%7Edfsg-1&stamp=1638035122&raw=0

lambdamusic commented 2 years ago

Hi @jonassmedegaard - thanks for the feedback.

I think this is because .instances defaults to False instead of a list.

The method .instances was a quick way to pull out class instances from the class - rather than extracting all of them in advance, which is what is required in order to build documentation pages programmatically.

The recent version 1.9.9.2 provides a more solid way to handle instances i.e. they can be all be extracted and indexed when Ontospy is instantiated (hide_individuals=False) by providing a flag.

I'll reset .instances to return an empty list by default. That should fix it

lambdamusic commented 2 years ago

https://github.com/lambdamusic/Ontospy/releases/tag/v1.9.9.3