From 5fd2a017b2759c598e1ea0bd5965049a003ce05c Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 12 Sep 2021 16:23:55 +0200 Subject: [PATCH] Fix imports --- telethon/__init__.py | 3 +-- telethon/_crypto/authkey.py | 2 +- telethon/_misc/__init__.py | 1 - telethon/_misc/binaryreader.py | 2 +- telethon/_misc/hints.py | 4 ++-- telethon/{types => _misc}/tlobject.py | 0 telethon/types/__init__.py | 16 ++++++++++++++++ telethon_generator/generators/docs.py | 2 +- telethon_generator/generators/tlobject.py | 6 +++--- telethon_generator/parsers/errors.py | 2 +- telethon_generator/parsers/tlobject/tlobject.py | 2 +- 11 files changed, 27 insertions(+), 13 deletions(-) rename telethon/{types => _misc}/tlobject.py (100%) create mode 100644 telethon/types/__init__.py diff --git a/telethon/__init__.py b/telethon/__init__.py index fa01de5b..59ea6691 100644 --- a/telethon/__init__.py +++ b/telethon/__init__.py @@ -2,8 +2,7 @@ from ._misc import helpers # no dependencies from . import _tl # no dependencies from ._misc import utils # depends on helpers and _tl -from ._tl import custom # depends on utils -from ._misc import hints # depends on custom +from ._misc import hints # depends on types/custom from ._client.telegramclient import TelegramClient from ._network import connection diff --git a/telethon/_crypto/authkey.py b/telethon/_crypto/authkey.py index fa6fbb78..54c66c76 100644 --- a/telethon/_crypto/authkey.py +++ b/telethon/_crypto/authkey.py @@ -4,7 +4,7 @@ This module holds the AuthKey class. import struct from hashlib import sha1 -from .._misc import BinaryReader +from .._misc.binaryreader import BinaryReader class AuthKey: diff --git a/telethon/_misc/__init__.py b/telethon/_misc/__init__.py index a3c77295..71c26b8a 100644 --- a/telethon/_misc/__init__.py +++ b/telethon/_misc/__init__.py @@ -3,4 +3,3 @@ Several extensions Python is missing, such as a proper class to handle a TCP communication with support for cancelling the operation, and a utility class to read arbitrary binary data in a more comfortable way, with int/strings/etc. """ -from .binaryreader import BinaryReader diff --git a/telethon/_misc/binaryreader.py b/telethon/_misc/binaryreader.py index e5c34c7f..34648a7a 100644 --- a/telethon/_misc/binaryreader.py +++ b/telethon/_misc/binaryreader.py @@ -10,7 +10,7 @@ from struct import unpack from ..errors import TypeNotFoundError from .. import _tl from .._tl.alltlobjects import tlobjects -from .._tl import core +from ..types import core _EPOCH_NAIVE = datetime(*time.gmtime(0)[:6]) _EPOCH = _EPOCH_NAIVE.replace(tzinfo=timezone.utc) diff --git a/telethon/_misc/hints.py b/telethon/_misc/hints.py index a5299a25..47f26a8f 100644 --- a/telethon/_misc/hints.py +++ b/telethon/_misc/hints.py @@ -3,7 +3,7 @@ import typing from . import helpers from .. import _tl -from .._tl import custom +from ..types import _custom Phone = str Username = str @@ -22,7 +22,7 @@ EntityLike = typing.Union[ ] EntitiesLike = typing.Union[EntityLike, typing.Sequence[EntityLike]] -ButtonLike = typing.Union[_tl.TypeKeyboardButton, custom.Button] +ButtonLike = typing.Union[_tl.TypeKeyboardButton, _custom.Button] MarkupLike = typing.Union[ _tl.TypeReplyMarkup, ButtonLike, diff --git a/telethon/types/tlobject.py b/telethon/_misc/tlobject.py similarity index 100% rename from telethon/types/tlobject.py rename to telethon/_misc/tlobject.py diff --git a/telethon/types/__init__.py b/telethon/types/__init__.py new file mode 100644 index 00000000..ac52ff6d --- /dev/null +++ b/telethon/types/__init__.py @@ -0,0 +1,16 @@ +from .._misc.tlobject import TLObject, TLRequest +from ._custom import ( + AdminLogEvent, + Draft, + Dialog, + InputSizedFile, + MessageButton, + Forward, + Message, + Button, + InlineBuilder, + InlineResult, + InlineResults, + QRLogin, + ParticipantPermissions, +) diff --git a/telethon_generator/generators/docs.py b/telethon_generator/generators/docs.py index d2da55d1..8b46e4d1 100755 --- a/telethon_generator/generators/docs.py +++ b/telethon_generator/generators/docs.py @@ -9,7 +9,7 @@ from pathlib import Path from ..docswriter import DocsWriter from ..parsers import TLObject, Usability -from .._misc.utils import snake_to_camel_case +from ..utils import snake_to_camel_case CORE_TYPES = { 'int', 'long', 'int128', 'int256', 'double', diff --git a/telethon_generator/generators/tlobject.py b/telethon_generator/generators/tlobject.py index 04003a6b..25c42e1e 100644 --- a/telethon_generator/generators/tlobject.py +++ b/telethon_generator/generators/tlobject.py @@ -7,7 +7,7 @@ from collections import defaultdict from zlib import crc32 from ..sourcebuilder import SourceBuilder -from .._misc.utils import snake_to_camel_case +from ..utils import snake_to_camel_case AUTO_GEN_NOTICE = \ '"""File generated by TLObjects\' generator. All changes will be ERASED"""' @@ -61,10 +61,10 @@ def _write_modules( builder.writeln(AUTO_GEN_NOTICE) if kind == 'TLObject': - builder.writeln('from .tlobject import TLObject, TLRequest') + builder.writeln('from .._misc.tlobject import TLObject, TLRequest') builder.writeln('from . import fn') else: - builder.writeln('from .. import TLObject, TLRequest') + builder.writeln('from ..._misc.tlobject import TLObject, TLRequest') builder.writeln('from typing import Optional, List, ' 'Union, TYPE_CHECKING') diff --git a/telethon_generator/parsers/errors.py b/telethon_generator/parsers/errors.py index 9bac2142..04cd3412 100644 --- a/telethon_generator/parsers/errors.py +++ b/telethon_generator/parsers/errors.py @@ -1,7 +1,7 @@ import csv import re -from .._misc.utils import snake_to_camel_case +from ..utils import snake_to_camel_case # Core base classes depending on the integer error code KNOWN_BASE_CLASSES = { diff --git a/telethon_generator/parsers/tlobject/tlobject.py b/telethon_generator/parsers/tlobject/tlobject.py index 0f753fa2..60b9e996 100644 --- a/telethon_generator/parsers/tlobject/tlobject.py +++ b/telethon_generator/parsers/tlobject/tlobject.py @@ -2,7 +2,7 @@ import re import struct import zlib -from ..._misc.utils import snake_to_camel_case +from ...utils import snake_to_camel_case # https://github.com/telegramdesktop/tdesktop/blob/4bf66cb6e93f3965b40084771b595e93d0b11bcd/Telegram/SourceFiles/codegen/scheme/codegen_scheme.py#L57-L62 WHITELISTED_MISMATCHING_IDS = {