|
19 | 19 |
|
20 | 20 | from __future__ import annotations |
21 | 21 |
|
22 | | -import re |
23 | | -from importlib import import_module |
24 | 22 | from typing import ClassVar |
25 | 23 |
|
26 | | -from .exceptions.all import exceptions |
27 | | -from .exceptions.bad_request_400 import BadRequest |
28 | | -from .exceptions.flood_420 import Flood |
29 | | -from .exceptions.forbidden_403 import Forbidden |
30 | | -from .exceptions.internal_server_error_500 import InternalServerError |
31 | | -from .exceptions.not_acceptable_406 import NotAcceptable |
32 | | -from .exceptions.see_other_303 import SeeOther |
33 | | -from .exceptions.service_unavailable_503 import ServiceUnavailable |
34 | | -from .exceptions.unauthorized_401 import Unauthorized |
35 | | -from .pyromod import ListenerStopped, ListenerTimeout |
36 | | -from .rpc_error import RPCError, UnknownError |
| 24 | +from .exceptions import * # noqa: F403 |
| 25 | +from .rpc_error import UnknownError |
37 | 26 |
|
38 | 27 |
|
39 | 28 | class BadMsgNotification(Exception): # noqa: N818 |
@@ -81,37 +70,10 @@ def __init__(self, msg: str | None = None): |
81 | 70 | super().__init__("A CDN file hash mismatch has occurred." if msg is None else msg) |
82 | 71 |
|
83 | 72 |
|
84 | | -error_objects = {} |
85 | | -for error_code, error_dict in exceptions.items(): |
86 | | - for error_name, class_name in error_dict.items(): |
87 | | - if error_name == "_": |
88 | | - continue |
89 | | - base = re.sub(r"(?<!^)(?=[A-Z])", "_", error_dict["_"]).lower() |
90 | | - module_name = f".exceptions.{base}_{error_code}" |
91 | | - try: |
92 | | - module = import_module(module_name, package="hydrogram.errors") |
93 | | - error_objects[class_name] = getattr(module, class_name) |
94 | | - except (ImportError, AttributeError): |
95 | | - continue |
96 | | - |
97 | | -locals().update(error_objects) |
98 | | - |
99 | 73 | __all__ = [ |
100 | 74 | "BadMsgNotification", |
101 | | - "BadRequest", |
102 | 75 | "CDNFileHashMismatch", |
103 | | - "Flood", |
104 | | - "Forbidden", |
105 | | - "InternalServerError", |
106 | | - "ListenerStopped", |
107 | | - "ListenerTimeout", |
108 | | - "NotAcceptable", |
109 | | - "RPCError", |
110 | 76 | "SecurityCheckMismatch", |
111 | 77 | "SecurityError", |
112 | | - "SeeOther", |
113 | | - "ServiceUnavailable", |
114 | | - "Unauthorized", |
115 | 78 | "UnknownError", |
116 | 79 | ] |
117 | | -__all__ += list(error_objects.keys()) # type: ignore |
0 commit comments