python-3.xinheritancezope.interface

Interface Inherited declaration


I'm trying to use an old code which has been developed by a Github developer. The code uses implements in zope.interface library to declare interfaces on a class's elements. Since implements in the library doesn't work anymore at Python 3.6, I confront with this error:

TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead.

Several websites have explained how to substitute implements with @implementer to work at Python 3.6, like here. But I haven't found any example to explain how to update the code when zope.interface.implements has been used as an inheritance. The code looks like this:

from zope.interface import implements
class Car(implements(Moveable)):
     def __init__(self, x, v, lane, model: IDM, lane_change: LaneChange,
             length):
...

I would like to update this code to work at Python 3.6. I've tried this

@implementer(Moveable) 
class Car:
     def __init__(self, x, v, lane, model: IDM, lane_change: LaneChange,
             length):

but it does n't work. Please help me to figure out how to make the above code running in Python 3.6.


Solution

  • Below steps solved the issue for me,

    pip uninstall apex
    git clone https://www.github.com/nvidia/apex
    cd apex
    python3 setup.py install