diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py
index 07435778..23e1db7d 100644
--- a/compiler/api/compiler.py
+++ b/compiler/api/compiler.py
@@ -442,12 +442,12 @@ def start(format: bool = False):
references, count = get_references(c.qualname, "constructors")
if references:
- docstring += f"\n Functions:\n This object can be returned by " \
+ docstring += "\n Functions:\n This object can be returned by " \
f"{count} function{'s' if count > 1 else ''}.\n\n" \
- f" .. currentmodule:: pyrogram.raw.functions\n\n" \
- f" .. autosummary::\n" \
- f" :nosignatures:\n\n" \
- f" " + references
+ " .. currentmodule:: pyrogram.raw.functions\n\n" \
+ " .. autosummary::\n" \
+ " :nosignatures:\n\n" \
+ " " + references
write_types = read_types = "" if c.has_flags else "# No flags\n "
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 60c8101e..946989f3 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -29,7 +29,7 @@ from pygments.styles.friendly import FriendlyStyle
FriendlyStyle.background_color = "#f3f2f1"
project = "Pyrofork"
-copyright = f"2022-present, Mayuri-Chan"
+copyright = "2022-present, Mayuri-Chan"
author = "Mayuri-Chan"
version = ".".join(__version__.split(".")[:-1])
diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py
index b5d3b5a5..04446e1c 100644
--- a/pyrogram/__init__.py
+++ b/pyrogram/__init__.py
@@ -17,13 +17,17 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see .
+from concurrent.futures.thread import ThreadPoolExecutor
+
+from . import raw, types, filters, handlers, emoji, enums
+from .client import Client
+from .sync import idle, compose
+
__fork_name__ = "PyroFork"
__version__ = "2.3.59"
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
__copyright__ = "Copyright (C) 2022-present Mayuri-Chan "
-from concurrent.futures.thread import ThreadPoolExecutor
-
class StopTransmission(Exception):
pass
@@ -36,9 +40,20 @@ class StopPropagation(StopAsyncIteration):
class ContinuePropagation(StopAsyncIteration):
pass
-
-from . import raw, types, filters, handlers, emoji, enums
-from .client import Client
-from .sync import idle, compose
-
crypto_executor = ThreadPoolExecutor(1, thread_name_prefix="CryptoWorker")
+
+__all__ = [
+ "Client",
+ "idle",
+ "compose",
+ "crypto_executor",
+ "StopTransmission",
+ "StopPropagation",
+ "ContinuePropagation",
+ "raw",
+ "types",
+ "filters",
+ "handlers",
+ "emoji",
+ "enums",
+]
diff --git a/pyrogram/client.py b/pyrogram/client.py
index 5c19df82..bffbbbc2 100644
--- a/pyrogram/client.py
+++ b/pyrogram/client.py
@@ -33,7 +33,7 @@ from importlib import import_module
from io import StringIO, BytesIO
from mimetypes import MimeTypes
from pathlib import Path
-from typing import Union, List, Optional, Callable, AsyncGenerator, Type, Tuple
+from typing import Union, List, Optional, Callable, AsyncGenerator, Tuple
import pyrogram
from pyrogram import __version__, __license__
@@ -51,24 +51,26 @@ from pyrogram.handlers.handler import Handler
from pyrogram.methods import Methods
from pyrogram.session import Auth, Session
from pyrogram.storage import FileStorage, MemoryStorage, Storage
+from pyrogram.types import User, TermsOfService
+from pyrogram.utils import ainput
+from .connection import Connection
+from .connection.transport import TCPAbridged
+from .dispatcher import Dispatcher
+from .file_id import FileId, FileType, ThumbnailSource
+from .mime_types import mime_types
+from .parser import Parser
+from .session.internals import MsgId
+
+log = logging.getLogger(__name__)
+MONGO_AVAIL = False
+
try:
import pymongo
except Exception:
pass
else:
from pyrogram.storage import MongoStorage
-from pyrogram.types import User, TermsOfService
-from pyrogram.utils import ainput
-from .connection import Connection
-from .connection.transport import TCP, TCPAbridged
-from .dispatcher import Dispatcher
-from .file_id import FileId, FileType, ThumbnailSource
-from .filters import Filter
-from .mime_types import mime_types
-from .parser import Parser
-from .session.internals import MsgId
-
-log = logging.getLogger(__name__)
+ MONGO_AVAIL = True
class Client(Methods):
@@ -316,9 +318,7 @@ class Client(Methods):
elif self.in_memory:
self.storage = MemoryStorage(self.name)
elif self.mongodb:
- try:
- import pymongo
- except Exception:
+ if not MONGO_AVAIL:
log.warning(
"pymongo is missing! "
"Using MemoryStorage as session storage"
@@ -953,7 +953,7 @@ class Client(Methods):
)
count += 1
- except Exception as e:
+ except Exception:
pass
else:
for path, handlers in include:
diff --git a/pyrogram/connection/transport/tcp/__init__.py b/pyrogram/connection/transport/tcp/__init__.py
index 2a906a2b..be86f6b4 100644
--- a/pyrogram/connection/transport/tcp/__init__.py
+++ b/pyrogram/connection/transport/tcp/__init__.py
@@ -23,3 +23,13 @@ from .tcp_abridged_o import TCPAbridgedO
from .tcp_full import TCPFull
from .tcp_intermediate import TCPIntermediate
from .tcp_intermediate_o import TCPIntermediateO
+
+__all__ = [
+ "TCP",
+ "Proxy",
+ "TCPAbridged",
+ "TCPAbridgedO",
+ "TCPFull",
+ "TCPIntermediate",
+ "TCPIntermediateO"
+]
diff --git a/pyrogram/crypto/mtproto.py b/pyrogram/crypto/mtproto.py
index 6b2ab3c4..6c17441a 100644
--- a/pyrogram/crypto/mtproto.py
+++ b/pyrogram/crypto/mtproto.py
@@ -71,7 +71,7 @@ def unpack(
message = Message.read(data)
except KeyError as e:
if e.args[0] == 0:
- raise ConnectionError(f"Received empty data. Check your internet connection.")
+ raise ConnectionError("Received empty data. Check your internet connection.")
left = data.read().hex()
@@ -79,7 +79,7 @@ def unpack(
left = [[left[i:i + 8] for i in range(0, len(left), 8)] for left in left]
left = "\n".join(" ".join(x for x in left) for left in left)
- raise ValueError(f"The server sent an unknown constructor: {hex(e.args[0])}\n{left}")
+ raise ValueError("The server sent an unknown constructor: {hex(e.args[0])}\n{left}")
# https://core.telegram.org/mtproto/security_guidelines#checking-sha256-hash-value-of-msg-key
# 96 = 88 + 8 (incoming message)
diff --git a/pyrogram/handlers/__init__.py b/pyrogram/handlers/__init__.py
index b4611cc6..7a381410 100644
--- a/pyrogram/handlers/__init__.py
+++ b/pyrogram/handlers/__init__.py
@@ -42,3 +42,31 @@ from .message_reaction_updated_handler import MessageReactionUpdatedHandler
from .message_reaction_count_updated_handler import MessageReactionCountUpdatedHandler
from .pre_checkout_query_handler import PreCheckoutQueryHandler
from .shipping_query_handler import ShippingQueryHandler
+
+__all__ = [
+ "BotBusinessConnectHandler",
+ "BotBusinessMessageHandler",
+ "CallbackQueryHandler",
+ "ChatJoinRequestHandler",
+ "ChatMemberUpdatedHandler",
+ "ConversationHandler",
+ "ChosenInlineResultHandler",
+ "DeletedMessagesHandler",
+ "DeletedBotBusinessMessagesHandler",
+ "DisconnectHandler",
+ "EditedMessageHandler",
+ "EditedBotBusinessMessageHandler",
+ "ErrorHandler",
+ "InlineQueryHandler",
+ "MessageHandler",
+ "PollHandler",
+ "PreCheckoutQueryHandler",
+ "PurchasedPaidMediaHandler",
+ "RawUpdateHandler",
+ "UserStatusHandler",
+ "StoryHandler",
+ "MessageReactionUpdatedHandler",
+ "MessageReactionCountUpdatedHandler",
+ "PreCheckoutQueryHandler",
+ "ShippingQueryHandler",
+]
diff --git a/pyrogram/helpers/helpers.py b/pyrogram/helpers/helpers.py
index 8aecc170..84f05f38 100644
--- a/pyrogram/helpers/helpers.py
+++ b/pyrogram/helpers/helpers.py
@@ -101,9 +101,9 @@ def kb(rows=None, **kwargs):
line = []
for button in row:
button_type = type(button)
- if button_type == str:
+ if isinstance(button_type, str):
button = KeyboardButton(button)
- elif button_type == dict:
+ elif isinstance(button_type, dict):
button = KeyboardButton(**button)
line.append(button)
diff --git a/pyrogram/methods/chats/hide_general_topic.py b/pyrogram/methods/chats/hide_general_topic.py
index 901758ca..44c72abb 100644
--- a/pyrogram/methods/chats/hide_general_topic.py
+++ b/pyrogram/methods/chats/hide_general_topic.py
@@ -17,7 +17,6 @@
# along with Pyrofork. If not, see .
import pyrogram
from pyrogram import raw
-from pyrogram import types
from typing import Union
diff --git a/pyrogram/methods/decorators/on_shipping_query.py b/pyrogram/methods/decorators/on_shipping_query.py
index 7128a88b..ee53233f 100644
--- a/pyrogram/methods/decorators/on_shipping_query.py
+++ b/pyrogram/methods/decorators/on_shipping_query.py
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
-from typing import Callable, Optional, Union
+from typing import Callable
import pyrogram
from pyrogram.filters import Filter
diff --git a/pyrogram/methods/messages/copy_media_group.py b/pyrogram/methods/messages/copy_media_group.py
index 485f77f8..98ba58ff 100644
--- a/pyrogram/methods/messages/copy_media_group.py
+++ b/pyrogram/methods/messages/copy_media_group.py
@@ -180,8 +180,12 @@ class CopyMediaGroup:
**await self.parser.parse(
captions[i] if isinstance(captions, list) and i < len(captions) and captions[i] else
captions if isinstance(captions, str) and i == 0 else
- message.caption if message.caption and message.caption != "None" and not type(
- captions) is str else "")
+ message.caption if (
+ message.caption
+ and message.caption != "None"
+ and not isinstance(captions, str)
+ ) else ""
+ )
)
)
diff --git a/pyrogram/parser/markdown.py b/pyrogram/parser/markdown.py
index 9d92a6d2..1b357b4f 100644
--- a/pyrogram/parser/markdown.py
+++ b/pyrogram/parser/markdown.py
@@ -18,7 +18,6 @@
# along with Pyrofork. If not, see .
import html
-import logging
import re
from typing import Optional
diff --git a/pyrogram/raw/core/__init__.py b/pyrogram/raw/core/__init__.py
index 1aeac260..7cf0aece 100644
--- a/pyrogram/raw/core/__init__.py
+++ b/pyrogram/raw/core/__init__.py
@@ -30,3 +30,24 @@ from .primitives.int import Int, Long, Int128, Int256
from .primitives.string import String
from .primitives.vector import Vector
from .tl_object import TLObject
+
+__all__ = [
+ "FutureSalt",
+ "FutureSalts",
+ "GzipPacked",
+ "List",
+ "Message",
+ "MsgContainer",
+ "Bool",
+ "BoolFalse",
+ "BoolTrue",
+ "Bytes",
+ "Double",
+ "Int",
+ "Long",
+ "Int128",
+ "Int256",
+ "String",
+ "Vector",
+ "TLObject"
+]
diff --git a/pyrogram/session/internals/__init__.py b/pyrogram/session/internals/__init__.py
index 1754586e..86f56250 100644
--- a/pyrogram/session/internals/__init__.py
+++ b/pyrogram/session/internals/__init__.py
@@ -20,3 +20,9 @@
from .data_center import DataCenter
from .msg_factory import MsgFactory
from .msg_id import MsgId
+
+__all__ = [
+ "DataCenter",
+ "MsgFactory",
+ "MsgId"
+]
diff --git a/pyrogram/types/__init__.py b/pyrogram/types/__init__.py
index 82460332..e1b90a73 100644
--- a/pyrogram/types/__init__.py
+++ b/pyrogram/types/__init__.py
@@ -30,3 +30,8 @@ from .update import *
from .user_and_chats import *
from .payments import *
from .pyromod import *
+
+__all__ = [
+ "List",
+ "Object"
+]
diff --git a/pyrogram/types/authorization/active_sessions.py b/pyrogram/types/authorization/active_sessions.py
index 414e3e70..b372c12a 100644
--- a/pyrogram/types/authorization/active_sessions.py
+++ b/pyrogram/types/authorization/active_sessions.py
@@ -18,8 +18,7 @@
from typing import List
-import pyrogram
-from pyrogram import raw, types, utils
+from pyrogram import raw, types
from ..object import Object
diff --git a/pyrogram/types/messages_and_media/stickerset.py b/pyrogram/types/messages_and_media/stickerset.py
index aa56165b..553cccee 100644
--- a/pyrogram/types/messages_and_media/stickerset.py
+++ b/pyrogram/types/messages_and_media/stickerset.py
@@ -16,11 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see .
-from typing import List, Optional, Union
-import pyrogram
from pyrogram import raw
-from pyrogram.file_id import FileId, FileType, FileUniqueId, FileUniqueType, ThumbnailSource
from ..object import Object
diff --git a/pyrogram/types/messages_and_media/transcribed_audio.py b/pyrogram/types/messages_and_media/transcribed_audio.py
index 0351ff1a..1231f319 100644
--- a/pyrogram/types/messages_and_media/transcribed_audio.py
+++ b/pyrogram/types/messages_and_media/transcribed_audio.py
@@ -57,7 +57,7 @@ class TranscribedAudio(Object):
self.trial_remains_until_date = trial_remains_until_date
@staticmethod
- def _parse(transcribe_result: "raw.types.messages.TranscribedAudio") -> "TranscribeAudio":
+ def _parse(transcribe_result: "raw.types.messages.TranscribedAudio") -> "TranscribedAudio":
return TranscribedAudio(
transcription_id=transcribe_result.transcription_id,
text=transcribe_result.text,
diff --git a/pyrogram/types/payments/input_stars_transaction.py b/pyrogram/types/payments/input_stars_transaction.py
index 156d2c45..77264c8c 100644
--- a/pyrogram/types/payments/input_stars_transaction.py
+++ b/pyrogram/types/payments/input_stars_transaction.py
@@ -16,8 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see .
-import pyrogram
-
from pyrogram import raw
from ..object import Object