Решение, которое также работает с наследуемыми классами:
from itertools import chain
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Mixin(object):
def as_dict(self):
tables = [base.__table__ for base in self.__class__.__bases__ if base not in [Base, Mixin]]
tables.append(self.__table__)
return {c.name: getattr(self, c.name) for c in chain.from_iterable([x.columns for x in tables])}
Нажмите шестерню слева внизу, затем выберите Settings
и выполните поиск wrappingIndent
в настройках, вы можете ее настроить.