I have zero idea as to why I'm getting this error.
as people said, the 2 arguments of issubclass()
should be classes, not instances of an object.
consider this sample:
>>> issubclass( 1, int )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: issubclass() arg 1 must be a class
>>> issubclass( type(1), int )
True
>>> isinstance( 1, int )
True
the key is the use of the type()
function to get the type of an instance for use with the issubclass()
function, which, as noted in another comment, is equivalent to calling isinstance()
It means that you don't provide a class as argument for issubclass()
. Both arguments have to be classes. Second argument can also be a tuple of classes.
If you show the code that throws this error, we can help further.
From the documentation:
issubclass(class, classinfo)
Returntrue
ifclass
is a subclass (direct or indirect) ofclassinfo
. A class is considered a subclass of itself.classinfo
may be a tuple of class objects, in which case every entry inclassinfo
will be checked. In any other case, aTypeError
exception is raised.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With