In the following example, the newly created subclass ends up being the metaclass __module__ rather than the parent classes' module. I've only seen this happen when using ABCMeta so it could be something specific to that module, anyone know what might be happening?
In [1]: from abc import ABCMeta
In [2]: class test(metaclass=ABCMeta):
...: pass
...:
In [3]: newclass = type('newclass', (test,), {})
In [4]: newclass.__module__
Out[4]: 'abc'
The behavior I want happens when I define the subclass in the more standard way:
In [5]: class subtest(test):
...: pass
...:
In [6]: subtest.__module__
Out[6]: '__main__'
Can someone explain why this is the case and how you could, using type, create a new subclass with the correct __module__ attribute inherited (e.g. __module__=='__main__')?