fix: typing issues in plugins
This commit is contained in:
parent
d27895e04e
commit
d0551c09ba
7 changed files with 18 additions and 11 deletions
|
@ -24,7 +24,9 @@ This plugin also respects security guidelines listed in XEP-0419.
|
|||
|
||||
from base64 import b64decode, b64encode
|
||||
from poezio.plugin_e2ee import E2EEPlugin
|
||||
from slixmpp import Message
|
||||
from poezio.tabs import ChatTab
|
||||
from slixmpp import Message, JID
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class Plugin(E2EEPlugin):
|
||||
|
@ -37,14 +39,14 @@ class Plugin(E2EEPlugin):
|
|||
# This encryption mechanism is using <body/> as a container
|
||||
replace_body_with_eme = False
|
||||
|
||||
def decrypt(self, message: Message, _tab) -> None:
|
||||
async def decrypt(self, message: Message, jid: Optional[JID], _tab: ChatTab) -> None:
|
||||
"""
|
||||
Decrypt base64
|
||||
"""
|
||||
body = message['body']
|
||||
message['body'] = b64decode(body.encode()).decode()
|
||||
|
||||
def encrypt(self, message: Message, _tab) -> None:
|
||||
async def encrypt(self, message: Message, jid: Optional[JID], _tab: ChatTab) -> None:
|
||||
"""
|
||||
Encrypt to base64
|
||||
"""
|
||||
|
|
|
@ -21,10 +21,12 @@ import os
|
|||
import re
|
||||
|
||||
from poezio.plugin import BasePlugin
|
||||
from typing import Dict
|
||||
|
||||
|
||||
class Plugin(BasePlugin):
|
||||
emoji_to_ascii = {}
|
||||
ascii_to_emoji = {}
|
||||
emoji_to_ascii: Dict[str, str] = {}
|
||||
ascii_to_emoji: Dict[str, str] = {}
|
||||
emoji_pattern = None
|
||||
alias_pattern = None
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
import io
|
||||
import logging
|
||||
import qrcode
|
||||
import sys
|
||||
|
||||
from typing import Dict, Callable
|
||||
|
||||
from poezio import windows
|
||||
from poezio.tabs import Tab
|
||||
|
|
|
@ -43,10 +43,10 @@ DEFAULT_CONFIG = {
|
|||
# overload if this is not how your stuff
|
||||
# is configured
|
||||
try:
|
||||
LOGIN = os.getlogin()
|
||||
LOGIN = os.getlogin() or ''
|
||||
LOGIN_TMUX = os.getuid()
|
||||
except Exception:
|
||||
LOGIN = os.getenv('USER')
|
||||
LOGIN = os.getenv('USER') or ''
|
||||
LOGIN_TMUX = os.getuid()
|
||||
|
||||
SCREEN_DIR = '/var/run/screens/S-%s' % LOGIN
|
||||
|
|
|
@ -49,7 +49,7 @@ def proxy(service: str) -> Callable[[str], str]:
|
|||
class Plugin(BasePlugin):
|
||||
"""UntrackMe"""
|
||||
|
||||
default_config: Dict[str, str] = {
|
||||
default_config: Dict[str, Dict[str, Union[str, bool]]] = {
|
||||
'default': {
|
||||
'cleanup': True,
|
||||
'redirect': True,
|
||||
|
|
|
@ -369,6 +369,8 @@ class Plugin(BasePlugin):
|
|||
return
|
||||
if activity[0]:
|
||||
general = ACTIVITIES.get(activity[0])
|
||||
if general is None:
|
||||
return
|
||||
s = general['category']
|
||||
if activity[1]:
|
||||
s = s + '/' + general.get(activity[1], 'other')
|
||||
|
|
|
@ -4,7 +4,7 @@ These are used in the plugin system added in poezio 0.7.5
|
|||
(see plugin_manager.py)
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, Set
|
||||
from typing import Any, Dict, Set, Optional
|
||||
from asyncio import iscoroutinefunction
|
||||
from functools import partial
|
||||
from configparser import RawConfigParser
|
||||
|
@ -404,7 +404,7 @@ class BasePlugin(object, metaclass=SafetyMetaclass):
|
|||
# Internal use only
|
||||
_unloading = False
|
||||
|
||||
default_config = None
|
||||
default_config: Optional[Dict[Any, Any]] = None
|
||||
dependencies: Set[str] = set()
|
||||
# This dict will get populated when the plugin is initialized
|
||||
refs: Dict[str, Any] = {}
|
||||
|
|
Loading…
Reference in a new issue