Coverage for slidge/core/mixins/base.py: 95%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-07 05:11 +0000

1from abc import ABCMeta 

2from typing import TYPE_CHECKING 

3 

4from slixmpp import JID 

5 

6from ...util.types import MessageOrPresenceTypeVar 

7 

8if TYPE_CHECKING: 

9 from ..gateway import BaseGateway 

10 from ..session import BaseSession 

11 

12 

13class MetaBase(ABCMeta): 

14 pass 

15 

16 

17class Base: 

18 session: "BaseSession" = NotImplemented 

19 xmpp: "BaseGateway" = NotImplemented 

20 

21 jid: JID = NotImplemented 

22 name: str = NotImplemented 

23 

24 @property 

25 def user_jid(self): 

26 return self.session.user_jid 

27 

28 @property 

29 def user_pk(self): 

30 return self.session.user_pk 

31 

32 

33class BaseSender(Base): 

34 def _send( 

35 self, stanza: MessageOrPresenceTypeVar, **send_kwargs 

36 ) -> MessageOrPresenceTypeVar: 

37 raise NotImplementedError