handler: fix more types

This commit is contained in:
mathieui 2021-07-05 22:28:38 +02:00
parent f2d7e86fc7
commit ed3bb878a7
4 changed files with 6 additions and 5 deletions

View File

@ -8,8 +8,9 @@ from __future__ import annotations
import weakref
from weakref import ReferenceType
from typing import Optional, TYPE_CHECKING
from typing import Optional, TYPE_CHECKING, Union
from slixmpp.xmlstream.matcher.base import MatcherBase
from xml.etree.ElementTree import Element
if TYPE_CHECKING:
from slixmpp.xmlstream import XMLStream, StanzaBase

View File

@ -45,13 +45,13 @@ class Callback(BaseHandler):
"""
_once: bool
_instream: bool
_pointer: Callable[[StanzaBase], Any]
def __init__(self, name: str, matcher: MatcherBase,
pointer: Callable[[StanzaBase], Any],
once: bool = False, instream: bool = False,
stream: Optional[XMLStream] = None):
BaseHandler.__init__(self, name, matcher, stream)
self._pointer: Callable[[StanzaBase], Any] = pointer
self._pointer = pointer
self._once = once
self._instream = instream

View File

@ -47,7 +47,6 @@ class CoroutineCallback(BaseHandler):
_once: bool
_instream: bool
_pointer: CoroutineFunction
def __init__(self, name: str, matcher: MatcherBase,
pointer: CoroutineFunction, once: bool = False,
@ -62,7 +61,7 @@ class CoroutineCallback(BaseHandler):
except Exception as e:
stanza.exception(e)
self._pointer = pointer_wrapper
self._pointer: CoroutineFunction = pointer_wrapper
self._once = once
self._instream = instream

View File

@ -8,7 +8,8 @@ from __future__ import annotations
import logging
from asyncio import Event, wait_for, TimeoutError
from typing import Optional, TYPE_CHECKING
from typing import Optional, TYPE_CHECKING, Union
from xml.etree.ElementTree import Element
import slixmpp
from slixmpp.xmlstream.stanzabase import StanzaBase