summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-03-26 11:50:29 +0100
committermathieui <mathieui@mathieui.net>2021-04-02 17:44:36 +0200
commitd0551c09ba8f5370ab3f40a9359687d5d7ed40bf (patch)
tree4fccbb5f489981a29c27596a45639e39319d8dbe
parentd27895e04e9100e9368a81756c0d679155a571d8 (diff)
downloadpoezio-d0551c09ba8f5370ab3f40a9359687d5d7ed40bf.tar.gz
poezio-d0551c09ba8f5370ab3f40a9359687d5d7ed40bf.tar.bz2
poezio-d0551c09ba8f5370ab3f40a9359687d5d7ed40bf.tar.xz
poezio-d0551c09ba8f5370ab3f40a9359687d5d7ed40bf.zip
fix: typing issues in plugins
-rw-r--r--plugins/b64.py8
-rw-r--r--plugins/emoji_ascii.py6
-rwxr-xr-xplugins/qr.py3
-rw-r--r--plugins/screen_detach.py4
-rw-r--r--plugins/untrackme.py2
-rw-r--r--plugins/user_extras.py2
-rw-r--r--poezio/plugin.py4
7 files changed, 18 insertions, 11 deletions
diff --git a/plugins/b64.py b/plugins/b64.py
index d56ac5b3..1fec6123 100644
--- a/plugins/b64.py
+++ b/plugins/b64.py
@@ -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
"""
diff --git a/plugins/emoji_ascii.py b/plugins/emoji_ascii.py
index 6629c50e..4beec3b1 100644
--- a/plugins/emoji_ascii.py
+++ b/plugins/emoji_ascii.py
@@ -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
diff --git a/plugins/qr.py b/plugins/qr.py
index 25530248..9b05750d 100755
--- a/plugins/qr.py
+++ b/plugins/qr.py
@@ -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
diff --git a/plugins/screen_detach.py b/plugins/screen_detach.py
index 0a2514c4..1f908513 100644
--- a/plugins/screen_detach.py
+++ b/plugins/screen_detach.py
@@ -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
diff --git a/plugins/untrackme.py b/plugins/untrackme.py
index c5db1a9d..ceddc5c5 100644
--- a/plugins/untrackme.py
+++ b/plugins/untrackme.py
@@ -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,
diff --git a/plugins/user_extras.py b/plugins/user_extras.py
index b66545ed..ad49a142 100644
--- a/plugins/user_extras.py
+++ b/plugins/user_extras.py
@@ -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')
diff --git a/poezio/plugin.py b/poezio/plugin.py
index 0ba13412..5fde7a12 100644
--- a/poezio/plugin.py
+++ b/poezio/plugin.py
@@ -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] = {}