def latestClass(oldClass):
    """
    Get the latest version of a class.
    """
    module = reflect.namedModule(oldClass.__module__)
    newClass = getattr(module, oldClass.__name__)
    newBases = [latestClass(base) for base in newClass.__bases__]

    try:
        # This makes old-style stuff work
        newClass.__bases__ = tuple(newBases)
        return newClass
    except TypeError:
        if newClass.__module__ in ("__builtin__", "builtins"):
            # __builtin__ members can't be reloaded sanely
            return newClass

        ctor = type(newClass)
        # The value of type(newClass) is the metaclass
        # in both Python 2 and 3, except if it was old-style.
        if _isClassType(ctor):
            ctor = getattr(newClass, '__metaclass__', type)
        return ctor(newClass.__name__, tuple(newBases),
                    dict(newClass.__dict__))

    Get the latest version of a class.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/rebuild.py