Refactor annotation style in handler.py | [Rework handler once (rejected)] (#996)

* Changed type annotation style to `typing.*` in dispatcher\handler.py

* Added a new argument `once` to the error handler registration that decides whether the following callback notifications should be made after a successful callback notification before in loop

* Revert "Added a new argument `once` to the error handler registration that decides whether the following callback notifications should be made after a successful callback notification before in loop"

This reverts commit 09448f1b71.
This commit is contained in:
Andrew 2022-10-02 19:49:43 +03:00 committed by GitHub
parent 4e78ce155b
commit d925ebf411
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
import inspect
import typing
from contextvars import ContextVar
from dataclasses import dataclass
from typing import Optional, Iterable, List
ctx_data = ContextVar('ctx_handler_data')
current_handler = ContextVar('current_handler')
@ -40,7 +40,7 @@ class Handler:
self.dispatcher = dispatcher
self.once = once
self.handlers: List[Handler.HandlerObj] = []
self.handlers: typing.List[Handler.HandlerObj] = []
self.middleware_key = middleware_key
def register(self, handler, filters=None, index=None):
@ -135,4 +135,4 @@ class Handler:
class HandlerObj:
handler: callable
spec: inspect.FullArgSpec
filters: Optional[Iterable[FilterObj]] = None
filters: typing.Optional[typing.Iterable[FilterObj]] = None