Browse Source

formatting: run isort across the codebase

Sumner Evans 3 years ago
parent
commit
899a5acd59

+ 2 - 2
mausignald/rpc.py

@@ -3,11 +3,11 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from typing import Optional, Dict, List, Callable, Awaitable, Any, Tuple
+from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple
 from uuid import UUID, uuid4
 from uuid import UUID, uuid4
 import asyncio
 import asyncio
-import logging
 import json
 import json
+import logging
 
 
 from mautrix.util.logging import TraceLogger
 from mautrix.util.logging import TraceLogger
 
 

+ 9 - 9
mausignald/signald.py

@@ -3,28 +3,28 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from typing import Union, Optional, List, Dict, Any, Callable, Awaitable, Set, TypeVar, Type
+from typing import Any, Awaitable, Callable, Dict, List, Optional, Set, Type, TypeVar, Union
 import asyncio
 import asyncio
 
 
 from mautrix.util.logging import TraceLogger
 from mautrix.util.logging import TraceLogger
 
 
-from .rpc import CONNECT_EVENT, DISCONNECT_EVENT, SignaldRPCClient
 from .errors import UnexpectedError, UnexpectedResponse
 from .errors import UnexpectedError, UnexpectedResponse
+from .rpc import CONNECT_EVENT, DISCONNECT_EVENT, SignaldRPCClient
 from .types import (
 from .types import (
+    Account,
     Address,
     Address,
-    Quote,
     Attachment,
     Attachment,
-    Reaction,
-    Account,
-    Message,
     DeviceInfo,
     DeviceInfo,
+    GetIdentitiesResponse,
     Group,
     Group,
-    Profile,
     GroupID,
     GroupID,
-    GetIdentitiesResponse,
     GroupV2,
     GroupV2,
-    Mention,
     LinkSession,
     LinkSession,
+    Mention,
+    Message,
+    Profile,
+    Quote,
+    Reaction,
     WebsocketConnectionState,
     WebsocketConnectionState,
     WebsocketConnectionStateChangeEvent,
     WebsocketConnectionStateChangeEvent,
 )
 )

+ 2 - 3
mausignald/types.py

@@ -3,13 +3,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from typing import Optional, Dict, List, NewType
+from typing import Dict, List, NewType, Optional
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
 from uuid import UUID
 from uuid import UUID
 
 
 from attr import dataclass
 from attr import dataclass
-
-from mautrix.types import SerializableAttrs, SerializableEnum, ExtensibleEnum, field
+from mautrix.types import ExtensibleEnum, SerializableAttrs, SerializableEnum, field
 
 
 GroupID = NewType("GroupID", str)
 GroupID = NewType("GroupID", str)
 
 

+ 7 - 6
mautrix_signal/__main__.py

@@ -13,7 +13,7 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Dict, Any
+from typing import Any, Dict
 from random import uniform
 from random import uniform
 import asyncio
 import asyncio
 import logging
 import logging
@@ -21,16 +21,17 @@ import logging
 from mautrix.bridge import Bridge
 from mautrix.bridge import Bridge
 from mautrix.types import RoomID, UserID
 from mautrix.types import RoomID, UserID
 
 
-from .version import version, linkified_version
+from . import commands
 from .config import Config
 from .config import Config
-from .db import upgrade_table, init as init_db
+from .db import init as init_db
+from .db import upgrade_table
 from .matrix import MatrixHandler
 from .matrix import MatrixHandler
-from .signal import SignalHandler
-from .user import User
 from .portal import Portal
 from .portal import Portal
 from .puppet import Puppet
 from .puppet import Puppet
+from .signal import SignalHandler
+from .user import User
+from .version import linkified_version, version
 from .web import ProvisioningAPI
 from .web import ProvisioningAPI
-from . import commands
 
 
 SYNC_JITTER = 10
 SYNC_JITTER = 10
 
 

+ 4 - 3
mautrix_signal/commands/auth.py

@@ -16,17 +16,18 @@
 from typing import Union
 from typing import Union
 import io
 import io
 
 
-from mausignald.errors import UnexpectedResponse, TimeoutException, AuthorizationFailedException
 from mautrix.appservice import IntentAPI
 from mautrix.appservice import IntentAPI
-from mautrix.types import MediaMessageEventContent, MessageType, ImageInfo, EventID
 from mautrix.bridge.commands import HelpSection, command_handler
 from mautrix.bridge.commands import HelpSection, command_handler
+from mautrix.types import EventID, ImageInfo, MediaMessageEventContent, MessageType
+
+from mausignald.errors import AuthorizationFailedException, TimeoutException, UnexpectedResponse
 
 
 from .. import puppet as pu
 from .. import puppet as pu
 from .typehint import CommandEvent
 from .typehint import CommandEvent
 
 
 try:
 try:
-    import qrcode
     import PIL as _
     import PIL as _
+    import qrcode
 except ImportError:
 except ImportError:
     qrcode = None
     qrcode = None
 
 

+ 2 - 1
mautrix_signal/commands/conn.py

@@ -13,8 +13,9 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from mautrix.types import EventID
 from mautrix.bridge.commands import HelpSection, command_handler
 from mautrix.bridge.commands import HelpSection, command_handler
+from mautrix.types import EventID
+
 from .typehint import CommandEvent
 from .typehint import CommandEvent
 
 
 SECTION_CONNECTION = HelpSection("Connection management", 15, "")
 SECTION_CONNECTION = HelpSection("Connection management", 15, "")

+ 6 - 4
mautrix_signal/commands/signal.py

@@ -17,18 +17,20 @@ from typing import Optional
 import base64
 import base64
 import json
 import json
 
 
-from mautrix.bridge.commands import HelpSection, command_handler, SECTION_ADMIN
+from mautrix.bridge.commands import SECTION_ADMIN, HelpSection, command_handler
 from mautrix.types import EventID
 from mautrix.types import EventID
-from mausignald.types import Address
+
 from mausignald.errors import UnknownIdentityKey
 from mausignald.errors import UnknownIdentityKey
+from mausignald.types import Address
 
 
-from .. import puppet as pu, portal as po
+from .. import portal as po
+from .. import puppet as pu
 from .auth import make_qr, remove_extra_chars
 from .auth import make_qr, remove_extra_chars
 from .typehint import CommandEvent
 from .typehint import CommandEvent
 
 
 try:
 try:
-    import qrcode
     import PIL as _
     import PIL as _
+    import qrcode
 except ImportError:
 except ImportError:
     qrcode = None
     qrcode = None
 
 

+ 1 - 1
mautrix_signal/commands/typehint.py

@@ -4,8 +4,8 @@ from mautrix.bridge.commands import CommandEvent as BaseCommandEvent
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
     from ..__main__ import SignalBridge
     from ..__main__ import SignalBridge
-    from ..user import User
     from ..portal import Portal
     from ..portal import Portal
+    from ..user import User
 
 
 
 
 class CommandEvent(BaseCommandEvent):
 class CommandEvent(BaseCommandEvent):

+ 3 - 3
mautrix_signal/config.py

@@ -16,10 +16,10 @@
 from typing import Any, List, NamedTuple
 from typing import Any, List, NamedTuple
 import os
 import os
 
 
-from mautrix.types import UserID
-from mautrix.client import Client
-from mautrix.util.config import ConfigUpdateHelper, ForbiddenKey, ForbiddenDefault
 from mautrix.bridge.config import BaseBridgeConfig
 from mautrix.bridge.config import BaseBridgeConfig
+from mautrix.client import Client
+from mautrix.types import UserID
+from mautrix.util.config import ConfigUpdateHelper, ForbiddenDefault, ForbiddenKey
 
 
 Permissions = NamedTuple("Permissions", relay=bool, user=bool, admin=bool, level=str)
 Permissions = NamedTuple("Permissions", relay=bool, user=bool, admin=bool, level=str)
 
 

+ 6 - 5
mautrix_signal/db/__init__.py

@@ -1,14 +1,15 @@
-from mautrix.util.async_db import Database
 import sqlite3
 import sqlite3
 import uuid
 import uuid
 
 
-from .upgrade import upgrade_table
+from mautrix.util.async_db import Database
+
 from .disappearing_message import DisappearingMessage
 from .disappearing_message import DisappearingMessage
-from .user import User
-from .puppet import Puppet
-from .portal import Portal
 from .message import Message
 from .message import Message
+from .portal import Portal
+from .puppet import Puppet
 from .reaction import Reaction
 from .reaction import Reaction
+from .upgrade import upgrade_table
+from .user import User
 
 
 
 
 def init(db: Database) -> None:
 def init(db: Database) -> None:

+ 3 - 4
mautrix_signal/db/disappearing_message.py

@@ -13,13 +13,12 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import ClassVar, List, Optional, TYPE_CHECKING
+from typing import TYPE_CHECKING, ClassVar, List, Optional
 
 
 from attr import dataclass
 from attr import dataclass
-import asyncpg
-
-from mautrix.types import RoomID, EventID
+from mautrix.types import EventID, RoomID
 from mautrix.util.async_db import Database
 from mautrix.util.async_db import Database
+import asyncpg
 
 
 fake_db = Database.create("") if TYPE_CHECKING else None
 fake_db = Database.create("") if TYPE_CHECKING else None
 
 

+ 3 - 3
mautrix_signal/db/message.py

@@ -13,15 +13,15 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Optional, ClassVar, Union, List, TYPE_CHECKING
+from typing import TYPE_CHECKING, ClassVar, List, Optional, Union
 from uuid import UUID
 from uuid import UUID
 
 
 from attr import dataclass
 from attr import dataclass
+from mautrix.types import EventID, RoomID
+from mautrix.util.async_db import Database
 import asyncpg
 import asyncpg
 
 
 from mausignald.types import Address, GroupID
 from mausignald.types import Address, GroupID
-from mautrix.types import RoomID, EventID
-from mautrix.util.async_db import Database
 
 
 from ..util import id_to_str
 from ..util import id_to_str
 
 

+ 3 - 3
mautrix_signal/db/portal.py

@@ -13,14 +13,14 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Optional, ClassVar, List, Union, TYPE_CHECKING
+from typing import TYPE_CHECKING, ClassVar, List, Optional, Union
 
 
 from attr import dataclass
 from attr import dataclass
+from mautrix.types import ContentURI, RoomID, UserID
+from mautrix.util.async_db import Database
 import asyncpg
 import asyncpg
 
 
 from mausignald.types import Address, GroupID
 from mausignald.types import Address, GroupID
-from mautrix.types import RoomID, ContentURI, UserID
-from mautrix.util.async_db import Database
 
 
 from ..util import id_to_str
 from ..util import id_to_str
 
 

+ 3 - 3
mautrix_signal/db/puppet.py

@@ -13,16 +13,16 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Optional, ClassVar, List, TYPE_CHECKING
+from typing import TYPE_CHECKING, ClassVar, List, Optional
 from uuid import UUID
 from uuid import UUID
 
 
 from attr import dataclass
 from attr import dataclass
+from mautrix.types import ContentURI, SyncToken, UserID
+from mautrix.util.async_db import Database
 from yarl import URL
 from yarl import URL
 import asyncpg
 import asyncpg
 
 
 from mausignald.types import Address
 from mausignald.types import Address
-from mautrix.types import UserID, SyncToken, ContentURI
-from mautrix.util.async_db import Database
 
 
 fake_db = Database.create("") if TYPE_CHECKING else None
 fake_db = Database.create("") if TYPE_CHECKING else None
 
 

+ 3 - 3
mautrix_signal/db/reaction.py

@@ -13,15 +13,15 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Optional, ClassVar, Union, TYPE_CHECKING
+from typing import TYPE_CHECKING, ClassVar, Optional, Union
 from uuid import UUID
 from uuid import UUID
 
 
 from attr import dataclass
 from attr import dataclass
+from mautrix.types import EventID, RoomID
+from mautrix.util.async_db import Database
 import asyncpg
 import asyncpg
 
 
 from mausignald.types import Address, GroupID
 from mausignald.types import Address, GroupID
-from mautrix.types import RoomID, EventID
-from mautrix.util.async_db import Database
 
 
 from ..util import id_to_str
 from ..util import id_to_str
 
 

+ 0 - 1
mautrix_signal/db/upgrade.py

@@ -14,7 +14,6 @@
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 from asyncpg import Connection
 from asyncpg import Connection
-
 from mautrix.util.async_db import UpgradeTable
 from mautrix.util.async_db import UpgradeTable
 
 
 upgrade_table = UpgradeTable()
 upgrade_table = UpgradeTable()

+ 2 - 3
mautrix_signal/db/user.py

@@ -13,12 +13,11 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Optional, ClassVar, List, TYPE_CHECKING
+from typing import TYPE_CHECKING, ClassVar, List, Optional
 from uuid import UUID
 from uuid import UUID
 
 
 from attr import dataclass
 from attr import dataclass
-
-from mautrix.types import UserID, RoomID
+from mautrix.types import RoomID, UserID
 from mautrix.util.async_db import Database
 from mautrix.util.async_db import Database
 
 
 fake_db = Database.create("") if TYPE_CHECKING else None
 fake_db = Database.create("") if TYPE_CHECKING else None

+ 10 - 12
mautrix_signal/formatter.py

@@ -13,21 +13,19 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Tuple, List, cast
+from typing import List, Tuple, cast
 from html import escape
 from html import escape
 import struct
 import struct
 
 
-from mausignald.types import MessageData, Address, Mention
-from mautrix.types import TextMessageEventContent, MessageType, Format
-from mautrix.util.formatter import (
-    MatrixParser as BaseMatrixParser,
-    EntityString,
-    SimpleEntity,
-    EntityType,
-    MarkdownString,
-)
-
-from . import puppet as pu, user as u
+from mautrix.types import Format, MessageType, TextMessageEventContent
+from mautrix.util.formatter import EntityString, EntityType, MarkdownString
+from mautrix.util.formatter import MatrixParser as BaseMatrixParser
+from mautrix.util.formatter import SimpleEntity
+
+from mausignald.types import Address, Mention, MessageData
+
+from . import puppet as pu
+from . import user as u
 
 
 
 
 # Helper methods from rom https://github.com/LonamiWebs/Telethon/blob/master/telethon/helpers.py
 # Helper methods from rom https://github.com/LonamiWebs/Telethon/blob/master/telethon/helpers.py

+ 2 - 2
mautrix_signal/get_version.py

@@ -1,6 +1,6 @@
-import subprocess
-import shutil
 import os
 import os
+import shutil
+import subprocess
 
 
 from . import __version__
 from . import __version__
 
 

+ 12 - 10
mautrix_signal/matrix.py

@@ -13,30 +13,32 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import List, Union, TYPE_CHECKING
+from typing import TYPE_CHECKING, List, Union
 
 
 from mautrix.bridge import BaseMatrixHandler
 from mautrix.bridge import BaseMatrixHandler
 from mautrix.types import (
 from mautrix.types import (
     Event,
     Event,
-    ReactionEvent,
-    StateEvent,
-    RoomID,
     EventID,
     EventID,
-    UserID,
-    TypingEvent,
-    ReactionEventContent,
-    RelationType,
     EventType,
     EventType,
-    ReceiptEvent,
     PresenceEvent,
     PresenceEvent,
+    ReactionEvent,
+    ReactionEventContent,
+    ReceiptEvent,
     RedactionEvent,
     RedactionEvent,
+    RelationType,
+    RoomID,
     SingleReceiptEventContent,
     SingleReceiptEventContent,
+    StateEvent,
+    TypingEvent,
+    UserID,
 )
 )
 
 
 from mautrix_signal.db.disappearing_message import DisappearingMessage
 from mautrix_signal.db.disappearing_message import DisappearingMessage
 
 
+from . import portal as po
+from . import signal as s
+from . import user as u
 from .db import Message as DBMessage
 from .db import Message as DBMessage
-from . import portal as po, user as u, signal as s
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
     from .__main__ import SignalBridge
     from .__main__ import SignalBridge

+ 56 - 54
mautrix_signal/portal.py

@@ -14,94 +14,96 @@
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 from typing import (
 from typing import (
-    Dict,
-    Tuple,
-    Optional,
-    List,
-    Deque,
+    TYPE_CHECKING,
     Any,
     Any,
-    Union,
     AsyncGenerator,
     AsyncGenerator,
     Awaitable,
     Awaitable,
-    Set,
     Callable,
     Callable,
-    TYPE_CHECKING,
+    Deque,
+    Dict,
+    List,
+    Optional,
+    Set,
+    Tuple,
+    Union,
     cast,
     cast,
 )
 )
-from html import escape as escape_html
 from collections import deque
 from collections import deque
-from uuid import UUID, uuid4
+from html import escape as escape_html
 from string import Template
 from string import Template
-import mimetypes
-import pathlib
-import hashlib
+from uuid import UUID, uuid4
 import asyncio
 import asyncio
+import hashlib
+import mimetypes
+import os
 import os.path
 import os.path
+import pathlib
 import time
 import time
-import os
 
 
-from mausignald.types import (
-    Address,
-    MessageData,
-    Reaction,
-    Quote,
-    Group,
-    Contact,
-    Profile,
-    Attachment,
-    GroupID,
-    GroupV2ID,
-    GroupV2,
-    Mention,
-    Sticker,
-    GroupAccessControl,
-    AccessControlMode,
-    GroupMemberRole,
-)
-from mausignald.errors import RPCError, ResponseError
 from mautrix.appservice import AppService, IntentAPI
 from mautrix.appservice import AppService, IntentAPI
 from mautrix.bridge import BasePortal, async_getter_lock
 from mautrix.bridge import BasePortal, async_getter_lock
+from mautrix.errors import IntentError, MatrixError, MForbidden
 from mautrix.types import (
 from mautrix.types import (
+    AudioInfo,
+    ContentURI,
+    EncryptedEvent,
     EventID,
     EventID,
-    MessageEventContent,
-    RoomID,
     EventType,
     EventType,
-    MessageType,
+    FileInfo,
     Format,
     Format,
-    MessageEvent,
-    EncryptedEvent,
-    ContentURI,
-    MediaMessageEventContent,
-    TextMessageEventContent,
     ImageInfo,
     ImageInfo,
-    VideoInfo,
-    FileInfo,
-    AudioInfo,
+    MediaMessageEventContent,
+    MessageEvent,
+    MessageEventContent,
+    MessageType,
     PowerLevelStateEventContent,
     PowerLevelStateEventContent,
-    UserID,
+    RoomID,
     SingleReceiptEventContent,
     SingleReceiptEventContent,
+    TextMessageEventContent,
+    UserID,
+    VideoInfo,
 )
 )
-from mautrix.util.format_duration import format_duration
 from mautrix.util.bridge_state import BridgeStateEvent
 from mautrix.util.bridge_state import BridgeStateEvent
+from mautrix.util.format_duration import format_duration
 from mautrix.util.message_send_checkpoint import MessageSendCheckpointStatus
 from mautrix.util.message_send_checkpoint import MessageSendCheckpointStatus
-from mautrix.errors import MatrixError, MForbidden, IntentError
 
 
-from .db import (
-    Portal as DBPortal,
-    Message as DBMessage,
-    Reaction as DBReaction,
-    DisappearingMessage,
+from mausignald.errors import ResponseError, RPCError
+from mausignald.types import (
+    AccessControlMode,
+    Address,
+    Attachment,
+    Contact,
+    Group,
+    GroupAccessControl,
+    GroupID,
+    GroupMemberRole,
+    GroupV2,
+    GroupV2ID,
+    Mention,
+    MessageData,
+    Profile,
+    Quote,
+    Reaction,
+    Sticker,
 )
 )
+
+from . import matrix as m
+from . import puppet as p
+from . import signal as s
+from . import user as u
 from .config import Config
 from .config import Config
+from .db import DisappearingMessage
+from .db import Message as DBMessage
+from .db import Portal as DBPortal
+from .db import Reaction as DBReaction
 from .formatter import matrix_to_signal, signal_to_matrix
 from .formatter import matrix_to_signal, signal_to_matrix
 from .util import id_to_str
 from .util import id_to_str
-from . import user as u, puppet as p, matrix as m, signal as s
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
     from .__main__ import SignalBridge
     from .__main__ import SignalBridge
 
 
 try:
 try:
-    from mautrix.crypto.attachments import encrypt_attachment, decrypt_attachment
+    from mautrix.crypto.attachments import decrypt_attachment, encrypt_attachment
 except ImportError:
 except ImportError:
     encrypt_attachment = decrypt_attachment = None
     encrypt_attachment = decrypt_attachment = None
 
 

+ 17 - 16
mautrix_signal/puppet.py

@@ -14,40 +14,41 @@
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 from typing import (
 from typing import (
-    Optional,
-    Dict,
+    TYPE_CHECKING,
+    AsyncGenerator,
     AsyncIterable,
     AsyncIterable,
     Awaitable,
     Awaitable,
-    AsyncGenerator,
-    Union,
+    Dict,
+    Optional,
     Tuple,
     Tuple,
-    TYPE_CHECKING,
+    Union,
     cast,
     cast,
 )
 )
 from uuid import UUID
 from uuid import UUID
-import hashlib
 import asyncio
 import asyncio
+import hashlib
 import os.path
 import os.path
 
 
-from yarl import URL
-
-from mausignald.types import Address, Contact, Profile
-from mautrix.bridge import BasePuppet, async_getter_lock
 from mautrix.appservice import IntentAPI
 from mautrix.appservice import IntentAPI
+from mautrix.bridge import BasePuppet, async_getter_lock
+from mautrix.errors import MForbidden
 from mautrix.types import (
 from mautrix.types import (
-    UserID,
-    SyncToken,
-    RoomID,
     ContentURI,
     ContentURI,
     EventType,
     EventType,
     PowerLevelStateEventContent,
     PowerLevelStateEventContent,
+    RoomID,
+    SyncToken,
+    UserID,
 )
 )
-from mautrix.errors import MForbidden
 from mautrix.util.simple_template import SimpleTemplate
 from mautrix.util.simple_template import SimpleTemplate
+from yarl import URL
 
 
-from .db import Puppet as DBPuppet
+from mausignald.types import Address, Contact, Profile
+
+from . import portal as p
+from . import user as u
 from .config import Config
 from .config import Config
-from . import portal as p, user as u
+from .db import Puppet as DBPuppet
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
     from .__main__ import SignalBridge
     from .__main__ import SignalBridge

+ 9 - 6
mautrix_signal/signal.py

@@ -13,26 +13,29 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Optional, List, TYPE_CHECKING
+from typing import TYPE_CHECKING, List, Optional
 import asyncio
 import asyncio
 import logging
 import logging
 
 
+from mautrix.util.logging import TraceLogger
+
 from mausignald import SignaldClient
 from mausignald import SignaldClient
 from mausignald.types import (
 from mausignald.types import (
+    Address,
     Message,
     Message,
     MessageData,
     MessageData,
-    Address,
-    TypingNotification,
-    TypingAction,
     OwnReadReceipt,
     OwnReadReceipt,
     Receipt,
     Receipt,
     ReceiptType,
     ReceiptType,
+    TypingAction,
+    TypingNotification,
     WebsocketConnectionStateChangeEvent,
     WebsocketConnectionStateChangeEvent,
 )
 )
-from mautrix.util.logging import TraceLogger
 
 
+from . import portal as po
+from . import puppet as pu
+from . import user as u
 from .db import Message as DBMessage
 from .db import Message as DBMessage
-from . import user as u, portal as po, puppet as pu
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
     from .__main__ import SignalBridge
     from .__main__ import SignalBridge

+ 11 - 9
mautrix_signal/user.py

@@ -13,30 +13,32 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
+from typing import TYPE_CHECKING, AsyncGenerator, Dict, List, Optional, Union, cast
 from asyncio.tasks import sleep
 from asyncio.tasks import sleep
 from datetime import datetime
 from datetime import datetime
-from typing import Union, Dict, Optional, AsyncGenerator, List, TYPE_CHECKING, cast
 from uuid import UUID
 from uuid import UUID
 import asyncio
 import asyncio
 
 
+from mautrix.appservice import AppService
+from mautrix.bridge import AutologinError, BaseUser, async_getter_lock
+from mautrix.types import RoomID, UserID
+from mautrix.util.bridge_state import BridgeState, BridgeStateEvent
+from mautrix.util.opt_prometheus import Gauge
+
 from mausignald.types import (
 from mausignald.types import (
     Account,
     Account,
     Address,
     Address,
-    Profile,
     Group,
     Group,
     GroupV2,
     GroupV2,
+    Profile,
     WebsocketConnectionState,
     WebsocketConnectionState,
     WebsocketConnectionStateChangeEvent,
     WebsocketConnectionStateChangeEvent,
 )
 )
-from mautrix.bridge import BaseUser, AutologinError, async_getter_lock
-from mautrix.types import UserID, RoomID
-from mautrix.util.bridge_state import BridgeState, BridgeStateEvent
-from mautrix.appservice import AppService
-from mautrix.util.opt_prometheus import Gauge
 
 
-from .db import User as DBUser
+from . import portal as po
+from . import puppet as pu
 from .config import Config
 from .config import Config
-from . import puppet as pu, portal as po
+from .db import User as DBUser
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
     from .__main__ import SignalBridge
     from .__main__ import SignalBridge

+ 2 - 1
mautrix_signal/util/color_log.py

@@ -13,7 +13,8 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from mautrix.util.logging.color import ColorFormatter as BaseColorFormatter, PREFIX, RESET
+from mautrix.util.logging.color import PREFIX, RESET
+from mautrix.util.logging.color import ColorFormatter as BaseColorFormatter
 
 
 MAUSIGNALD_COLOR = PREFIX + "35;1m"  # magenta
 MAUSIGNALD_COLOR = PREFIX + "35;1m"  # magenta
 
 

+ 1 - 1
mautrix_signal/version.py

@@ -1 +1 @@
-from .get_version import git_tag, git_revision, version, linkified_version
+from .get_version import git_revision, git_tag, linkified_version, version

+ 5 - 5
mautrix_signal/web/provisioning_api.py

@@ -13,18 +13,18 @@
 #
 #
 # You should have received a copy of the GNU Affero General Public License
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
-from typing import Awaitable, Dict, TYPE_CHECKING
-import logging
+from typing import TYPE_CHECKING, Awaitable, Dict
 import asyncio
 import asyncio
 import json
 import json
+import logging
 
 
 from aiohttp import web
 from aiohttp import web
-
-from mausignald.types import Address, Account
-from mausignald.errors import InternalError, TimeoutException
 from mautrix.types import UserID
 from mautrix.types import UserID
 from mautrix.util.logging import TraceLogger
 from mautrix.util.logging import TraceLogger
 
 
+from mausignald.errors import InternalError, TimeoutException
+from mausignald.types import Account, Address
+
 from .. import user as u
 from .. import user as u
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING: