Skip to content

Commit aafc27b

Browse files
authored
Reactor exceptions parameter's normalization
1 parent 7cfa504 commit aafc27b

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

pyrogram/handlers/error_handler.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from collections.abc import Sequence
20-
from typing import Callable
20+
from typing import Callable, Optional
2121

2222
import pyrogram
2323
from pyrogram.filters import Filter
@@ -78,14 +78,13 @@ class ErrorHandler(Handler):
7878
def __init__(
7979
self,
8080
callback: Callable,
81-
filters: Filter | None = None,
82-
exceptions: Exception | Sequence[Exception] | None = None
81+
filters: Optional[Filter] = None,
82+
exceptions: Optional[type[Exception] | Sequence[type[Exception]]] = None
8383
):
8484
super().__init__(callback, filters)
8585

86-
exceptions = exceptions or (Exception,)
87-
if not isinstance(exceptions, tuple):
88-
exceptions = (exceptions,)
89-
90-
self.exceptions = exceptions
91-
86+
self.exceptions: tuple[Exception] = (
87+
tuple(exceptions)
88+
if isinstance(exceptions, Sequence)
89+
else exceptions or (Exception,)
90+
)

0 commit comments

Comments
 (0)