Closed pbauer closed 6 years ago
What about using
import inspect
if inspect.isclass(mt):
mt = mt()
Anyway, overall the whole assumption is ugly.
I am fine to merge the PR as it is.
Anyway a possible fix for the missing InstanceType is:
try:
from types import InstanceType
except ImportError:
InstanceType = object
@ale-rt your approach would always return true (since isinstance(xx, object)
is true for classes and instances of classes.
I think inspect.isclass(xx)
is correct though.
Right!
I'm not sure how to deal with the
isinstance(mt, InstanceType)
thing. InstanceType should only apply to old-style classes (not inheriting from object) which are gone in py3 (all classes inherit from object) but here it looks like it is (ab)used to check if mimetype class has been instanciated or not. I did not really look what a mt is so some help would be nice.