summaryrefslogtreecommitdiff
path: root/poezio/tabs
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-08-15 14:21:59 +0200
committermathieui <mathieui@mathieui.net>2018-08-15 14:23:00 +0200
commit5ea82ac0af1cb855c9333796004c6a97da6b5ad4 (patch)
treef737e7e25012b76324ae03b591e19266a113a845 /poezio/tabs
parentcccb1d97591966de1bab1b293294eefb17b90aac (diff)
downloadpoezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.tar.gz
poezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.tar.bz2
poezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.tar.xz
poezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.zip
Fix mypy errors, add type annotations
Diffstat (limited to 'poezio/tabs')
-rw-r--r--poezio/tabs/adhoc_commands_list.py9
-rw-r--r--poezio/tabs/basetabs.py9
-rw-r--r--poezio/tabs/bookmarkstab.py12
-rw-r--r--poezio/tabs/confirmtab.py9
-rw-r--r--poezio/tabs/conversationtab.py22
-rw-r--r--poezio/tabs/data_forms.py8
-rw-r--r--poezio/tabs/listtab.py13
-rw-r--r--poezio/tabs/muclisttab.py9
-rw-r--r--poezio/tabs/muctab.py12
-rw-r--r--poezio/tabs/privatetab.py14
-rw-r--r--poezio/tabs/rostertab.py14
11 files changed, 79 insertions, 52 deletions
diff --git a/poezio/tabs/adhoc_commands_list.py b/poezio/tabs/adhoc_commands_list.py
index fecfc9e2..b62166b0 100644
--- a/poezio/tabs/adhoc_commands_list.py
+++ b/poezio/tabs/adhoc_commands_list.py
@@ -5,16 +5,19 @@ nothing.
"""
import logging
-log = logging.getLogger(__name__)
+from typing import Dict, Callable
from poezio.tabs import ListTab
+from poezio.core.structs import Command
from slixmpp.plugins.xep_0030.stanza.items import DiscoItem
+log = logging.getLogger(__name__)
+
class AdhocCommandsListTab(ListTab):
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, jid):
ListTab.__init__(
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index 6a35bb51..578668fc 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -90,8 +90,11 @@ SHOW_NAME = {
class Tab:
- plugin_commands = {}
+ plugin_commands = {} # type: Dict[str, Command]
plugin_keys = {} # type: Dict[str, Callable]
+ # Placeholder values, set on resize
+ height = 1
+ width = 1
def __init__(self, core):
self.core = core
@@ -455,8 +458,8 @@ class ChatTab(Tab):
Also, ^M is already bound to on_enter
And also, add the /say command
"""
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
message_type = 'chat'
def __init__(self, core, jid=''):
diff --git a/poezio/tabs/bookmarkstab.py b/poezio/tabs/bookmarkstab.py
index 1ee623c5..816402a7 100644
--- a/poezio/tabs/bookmarkstab.py
+++ b/poezio/tabs/bookmarkstab.py
@@ -3,27 +3,31 @@ Defines the data-forms Tab
"""
import logging
-log = logging.getLogger(__name__)
+from typing import Dict, Callable, List
from poezio import windows
from poezio.bookmarks import Bookmark, BookmarkList
+from poezio.core.structs import Command
from poezio.tabs import Tab
from poezio.common import safeJID
+log = logging.getLogger(__name__)
+
class BookmarksTab(Tab):
"""
A tab displaying lines of bookmarks, each bookmark having
a 4 widgets to set the jid/password/autojoin/storage method
"""
- plugin_commands = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, bookmarks: BookmarkList):
Tab.__init__(self, core)
self.name = "Bookmarks"
self.bookmarks = bookmarks
- self.new_bookmarks = []
- self.removed_bookmarks = []
+ self.new_bookmarks = [] # type: List[Bookmark]
+ self.removed_bookmarks = [] # type: List[Bookmark]
self.header_win = windows.ColumnHeaderWin(
('name', 'room@server/nickname', 'password', 'autojoin',
'storage'))
diff --git a/poezio/tabs/confirmtab.py b/poezio/tabs/confirmtab.py
index 545bb761..c76883dd 100644
--- a/poezio/tabs/confirmtab.py
+++ b/poezio/tabs/confirmtab.py
@@ -3,15 +3,18 @@ A generic tab that displays a text and a boolean choice
"""
import logging
-log = logging.getLogger(__name__)
+from typing import Dict, Callable
from poezio import windows
+from poezio.core.structs import Command
from poezio.tabs import Tab
+log = logging.getLogger(__name__)
+
class ConfirmTab(Tab):
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self,
core,
diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py
index 0d68b9b8..7e7a7488 100644
--- a/poezio/tabs/conversationtab.py
+++ b/poezio/tabs/conversationtab.py
@@ -11,10 +11,9 @@ There are two different instances of a ConversationTab:
the time.
"""
-import logging
-log = logging.getLogger(__name__)
-
import curses
+import logging
+from typing import Dict, Callable
from poezio.tabs.basetabs import OneToOneTab, Tab
@@ -23,21 +22,24 @@ from poezio import windows
from poezio import xhtml
from poezio.common import safeJID
from poezio.config import config
+from poezio.core.structs import Command
from poezio.decorators import refresh_wrapper
from poezio.roster import roster
from poezio.text_buffer import CorrectionError
from poezio.theming import get_theme, dump_tuple
from poezio.decorators import command_args_parser
+log = logging.getLogger(__name__)
+
class ConversationTab(OneToOneTab):
"""
The tab containg a normal conversation (not from a MUC)
Must not be instantiated, use Static or Dynamic version only.
"""
- plugin_commands = {}
- plugin_keys = {}
- additional_information = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
+ additional_information = {} # type: Dict[str, Callable[[str], str]]
message_type = 'chat'
def __init__(self, core, jid):
@@ -409,8 +411,8 @@ class DynamicConversationTab(ConversationTab):
bad idea so it has been removed.
Only one DynamicConversationTab can be opened for a given jid.
"""
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, jid, resource=None):
self.locked_resource = None
@@ -479,8 +481,8 @@ class StaticConversationTab(ConversationTab):
A conversation tab associated with one Full JID. It cannot be locked to
an different resource or unlocked.
"""
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, jid):
assert (safeJID(jid).resource)
diff --git a/poezio/tabs/data_forms.py b/poezio/tabs/data_forms.py
index d216d4ca..496863bc 100644
--- a/poezio/tabs/data_forms.py
+++ b/poezio/tabs/data_forms.py
@@ -3,10 +3,13 @@ Defines the data-forms Tab
"""
import logging
-log = logging.getLogger(__name__)
+from typing import Dict, Callable
from poezio import windows
from poezio.tabs import Tab
+from poezio.core.structs import Command
+
+log = logging.getLogger(__name__)
class DataFormsTab(Tab):
@@ -14,7 +17,8 @@ class DataFormsTab(Tab):
A tab contaning various window type, displaying
a form that the user needs to fill.
"""
- plugin_commands = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, form, on_cancel, on_send, kwargs):
Tab.__init__(self, core)
diff --git a/poezio/tabs/listtab.py b/poezio/tabs/listtab.py
index 1c96f778..6a4da08e 100644
--- a/poezio/tabs/listtab.py
+++ b/poezio/tabs/listtab.py
@@ -4,21 +4,22 @@ sortable list. It should be inherited, to actually provide methods that
insert items in the list, and that lets the user interact with them.
"""
-import logging
-log = logging.getLogger(__name__)
-
import curses
import collections
+import logging
+from typing import Dict, Callable
from poezio import windows
+from poezio.core.structs import Command
from poezio.decorators import refresh_wrapper
-
from poezio.tabs import Tab
+log = logging.getLogger(__name__)
+
class ListTab(Tab):
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, name, help_message, header_text, cols):
"""Parameters:
diff --git a/poezio/tabs/muclisttab.py b/poezio/tabs/muclisttab.py
index 6ba7816d..aac25787 100644
--- a/poezio/tabs/muclisttab.py
+++ b/poezio/tabs/muclisttab.py
@@ -5,20 +5,23 @@ It has no functionality except scrolling the list, and allowing the
user to join the rooms.
"""
import logging
-log = logging.getLogger(__name__)
+from typing import Dict, Callable
from poezio.tabs import ListTab
+from poezio.core.structs import Command
from slixmpp.plugins.xep_0030.stanza.items import DiscoItem
+log = logging.getLogger(__name__)
+
class MucListTab(ListTab):
"""
A tab listing rooms from a specific server, displaying various information,
scrollable, and letting the user join them, etc
"""
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, server):
ListTab.__init__(self, core, server.full, "“j”: join room.",
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index 4ec973a9..934dc0b1 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -7,15 +7,14 @@ It keeps track of many things such as part/joins, maintains an
user list, and updates private tabs when necessary.
"""
-import logging
-log = logging.getLogger(__name__)
-
import bisect
import curses
+import logging
import os
import random
import re
from datetime import datetime
+from typing import Dict, Callable
from poezio.tabs import ChatTab, Tab, SHOW_NAME
@@ -27,6 +26,7 @@ from poezio import windows
from poezio import xhtml
from poezio.common import safeJID
from poezio.config import config
+from poezio.core.structs import Command
from poezio.decorators import refresh_wrapper, command_args_parser
from poezio.logger import logger
from poezio.roster import roster
@@ -34,6 +34,8 @@ from poezio.theming import get_theme, dump_tuple
from poezio.user import User
from poezio.core.structs import Completion, Status
+log = logging.getLogger(__name__)
+
NS_MUC_USER = 'http://jabber.org/protocol/muc#user'
STATUS_XPATH = '{%s}x/{%s}status' % (NS_MUC_USER, NS_MUC_USER)
@@ -44,8 +46,8 @@ class MucTab(ChatTab):
It contains an userlist, an input, a topic, an information and a chat zone
"""
message_type = 'groupchat'
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, jid, nick, password=None):
ChatTab.__init__(self, core, jid)
diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py
index bc7f31c7..8f5f4d6f 100644
--- a/poezio/tabs/privatetab.py
+++ b/poezio/tabs/privatetab.py
@@ -10,10 +10,9 @@ both participant’s nicks. It also has slightly different features than
the ConversationTab (such as tab-completion on nicks from the room).
"""
-import logging
-log = logging.getLogger(__name__)
-
import curses
+import logging
+from typing import Dict, Callable
from poezio.tabs import OneToOneTab, MucTab, Tab
@@ -21,20 +20,23 @@ from poezio import windows
from poezio import xhtml
from poezio.common import safeJID
from poezio.config import config
+from poezio.core.structs import Command
from poezio.decorators import refresh_wrapper
from poezio.logger import logger
from poezio.theming import get_theme, dump_tuple
from poezio.decorators import command_args_parser
+log = logging.getLogger(__name__)
+
class PrivateTab(OneToOneTab):
"""
The tab containg a private conversation (someone from a MUC)
"""
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
message_type = 'chat'
- plugin_commands = {}
- additional_information = {}
- plugin_keys = {}
+ additional_information = {} # type: Dict[str, Callable[[str], str]]
def __init__(self, core, name, nick):
OneToOneTab.__init__(self, core, name)
diff --git a/poezio/tabs/rostertab.py b/poezio/tabs/rostertab.py
index 2941159c..43c612d0 100644
--- a/poezio/tabs/rostertab.py
+++ b/poezio/tabs/rostertab.py
@@ -6,16 +6,15 @@ rectangle shows the current contact info.
This module also includes functions to match users in the roster.
"""
import logging
-log = logging.getLogger(__name__)
-
import base64
import curses
import difflib
import os
import ssl
-from os import getenv, path
from functools import partial
+from os import getenv, path
from pathlib import Path
+from typing import Dict, Callable
from poezio import common
from poezio import windows
@@ -26,17 +25,18 @@ from poezio.decorators import refresh_wrapper
from poezio.roster import RosterGroup, roster
from poezio.theming import get_theme, dump_tuple
from poezio.decorators import command_args_parser
-from poezio.core.structs import Completion
-
+from poezio.core.structs import Command, Completion
from poezio.tabs import Tab
+log = logging.getLogger(__name__)
+
class RosterInfoTab(Tab):
"""
A tab, splitted in two, containing the roster and infos
"""
- plugin_commands = {}
- plugin_keys = {}
+ plugin_commands = {} # type: Dict[str, Command]
+ plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core):
Tab.__init__(self, core)