Search code examples
pythonoopinheritancepylint

Python Error :Inheriting 'X', which is not a class


I have written the code using Visual Studio code

from datetime import date

Title = 'Actividad #$'
Complexity = 0
Time = 5 #cantidad en dias

class Activitie(Title,Complexity,Time):
    """Log your activity with this class"""

    Title = 'Actividad #$'
    Complexity = 0
    Time = 5 #cantidad en dias

And it shows

Inheriting 'Time', which is not a class.
Inheriting 'Complexity', which is not a class.
Inheriting 'Title', which is not a class.

and ...

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Thank you for any solution


Solution

  • Looks like you want to define the class object constructor, but you've accidentally done it using Python's class inheritance syntax.

    Here's how to define a class and its object constructor:

    class Activitie:
        def __init__(self, Title, Complexity, Time):
        """Log your activity with this class"""
    
            self.Title = Title
            self.Complexity = Complexity
            self.Time = Time 
    

    Your getting this Inheritance error because the syntax for declaring inheritance in Python looks like this:

    SubClass(ParentClassA, ParentClassB, ParentClassC):