# HG changeset patch # User Goffi # Date 1663791643 -7200 # Node ID 045af0eeda3fc46ce5eed519470f8741e537b10e # Parent ba78cc0c8d5935621895daa58530c61c063db98d core, CLI (base), tools (common/data_format): typing/core readability diff -r ba78cc0c8d59 -r 045af0eeda3f sat/memory/sqla.py --- a/sat/memory/sqla.py Wed Aug 31 17:07:03 2022 +0200 +++ b/sat/memory/sqla.py Wed Sep 21 22:20:43 2022 +0200 @@ -16,61 +16,67 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import sys -import time import asyncio +from asyncio.subprocess import PIPE import copy from datetime import datetime -from asyncio.subprocess import PIPE from pathlib import Path -from typing import Union, Dict, List, Tuple, Iterable, Any, Callable, Optional -from sqlalchemy.ext.asyncio import AsyncSession, AsyncEngine, create_async_engine +import sys +import time +from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union + +from alembic import config as al_config, script as al_script +from alembic.runtime import migration as al_migration +from sqlalchemy import and_, delete, event, func, or_, update +from sqlalchemy import Integer, literal_column, text +from sqlalchemy.dialects.sqlite import insert +from sqlalchemy.engine import Connection, Engine from sqlalchemy.exc import IntegrityError, NoResultFound +from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine +from sqlalchemy.future import select from sqlalchemy.orm import ( - sessionmaker, subqueryload, joinedload, selectinload, contains_eager + contains_eager, + joinedload, + selectinload, + sessionmaker, + subqueryload, ) +from sqlalchemy.orm.attributes import Mapped from sqlalchemy.orm.decl_api import DeclarativeMeta -from sqlalchemy.orm.attributes import Mapped -from sqlalchemy.future import select -from sqlalchemy.engine import Engine, Connection -from sqlalchemy import update, delete, and_, or_, event, func -from sqlalchemy.sql.functions import coalesce, sum as sum_, now, count -from sqlalchemy.dialects.sqlite import insert -from sqlalchemy import text, literal_column, Integer -from alembic import script as al_script, config as al_config -from alembic.runtime import migration as al_migration +from sqlalchemy.sql.functions import coalesce, count, now, sum as sum_ from twisted.internet import defer from twisted.words.protocols.jabber import jid from twisted.words.xish import domish -from sat.core.i18n import _ + from sat.core import exceptions -from sat.core.log import getLogger from sat.core.constants import Const as C from sat.core.core_types import SatXMPPEntity -from sat.tools.utils import aio, as_future -from sat.tools.common import uri +from sat.core.i18n import _ +from sat.core.log import getLogger from sat.memory import migration from sat.memory import sqla_config from sat.memory.sqla_mapping import ( - NOT_IN_EXTRA, - SyncState, Base, - Profile, Component, + File, History, Message, - Subject, - Thread, + NOT_IN_EXTRA, ParamGen, ParamInd, PrivateGen, + PrivateGenBin, PrivateInd, - PrivateGenBin, PrivateIndBin, - File, + Profile, + PubsubItem, PubsubNode, - PubsubItem, + Subject, + SyncState, + Thread, ) +from sat.tools.common import uri +from sat.tools.utils import aio, as_future log = getLogger(__name__) diff -r ba78cc0c8d59 -r 045af0eeda3f sat/tools/common/data_format.py --- a/sat/tools/common/data_format.py Wed Aug 31 17:07:03 2022 +0200 +++ b/sat/tools/common/data_format.py Wed Sep 21 22:20:43 2022 +0200 @@ -20,6 +20,8 @@ """ tools common to backend and frontends """ #  FIXME: json may be more appropriate than manual serialising like done here +from typing import Any + from sat.core import exceptions import json @@ -133,7 +135,7 @@ """ return json.dumps(data, ensure_ascii=False, default=str) -def deserialise(serialised_data, default=None, type_check=dict): +def deserialise(serialised_data: str, default: Any = None, type_check: type = dict): """Deserialize data from bridge @param serialised_data(unicode): data to deserialise diff -r ba78cc0c8d59 -r 045af0eeda3f sat_frontends/jp/base.py --- a/sat_frontends/jp/base.py Wed Aug 31 17:07:03 2022 +0200 +++ b/sat_frontends/jp/base.py Wed Sep 21 22:20:43 2022 +0200 @@ -1255,7 +1255,7 @@ """Helper method to compute extra data from pubsub arguments @param extra: base extra dict, or None to generate a new one - @return: dict which can be used directly in the bridge for pubsub + @return: serialised dict which can be used directly in the bridge for pubsub """ if extra is None: extra = {}