Forward Declarations bug?

classic Classic list List threaded Threaded
5 messages Options
rdk
Reply | Threaded
Open this post in threaded view
|

Forward Declarations bug?

rdk
Hi,

I'm attempting to use Forward Declarations in my code but keep getting the same error:

Traceback (most recent call last):
  File "C:\Python_VEnvs\Debug\debug__Forward-Declarations.py", line 21, in <module>
    class Bug(Thing):
  File "C:\Python_VEnvs\lib\site-packages\owlready2\entity.py", line 147, in __init__
    delattr(Class, k) # Remove the value initially stored by obj_dict in __new__
AttributeError: comment


Sample code:

with debug:
        class Bug(Thing): pass

        class Bugger(Bug):
                comment = [locstr('It is a bugger...', lang = 'en')]

        class Bug(Thing):
                comment = [locstr('This is the BUG!', lang = 'en')]


Is this a bug?

Cheers,
Rui
Reply | Threaded
Open this post in threaded view
|

Re: Forward Declarations bug?

Jiba
Administrator
Hi,

There was a bug when properties were added at the class definition level. I fixed it the the development version.

As a workaround, you can also do:

        class Bugger(Bug):
                pass
        Bugger.comment = [locstr('It is a bugger...', lang = 'en')]

Thank you,
Jiba
rdk
Reply | Threaded
Open this post in threaded view
|

Re: Forward Declarations bug?

rdk
Thanks to you, Jean-Baptiste, for the creation and development of Owlready ;)

Cheers,
Rui
rdk
Reply | Threaded
Open this post in threaded view
|

Re: Forward Declarations bug?

rdk
In reply to this post by Jiba
Hi Jean-Baptiste,

Just noticed the same error happens with Labels...

Cheers,
Rui
Reply | Threaded
Open this post in threaded view
|

Re: Forward Declarations bug?

Jiba
Administrator
In reply to this post by rdk
Hi,

I tested the following (with the development version of Owlready) and it works well... If it works for comment, it should work also for label?


with onto:
    class Bug(Thing): pass
   
    class Bugger(Bug):
        label = [locstr('It is a bugger...', lang = 'en')]
       
    class Bug(Thing):
        label = [locstr('This is the BUG!', lang = 'en')]

Best regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13