Philipp Hörist pushed to branch master at gajim / gajim
Commits: b70549dd by Philipp Hörist at 2018-09-21T21:53:16Z Add __init__.py to gajim/dev
- - - - - d722a855 by Philipp Hörist at 2018-09-21T21:53:50Z Fix pylint errors in ipython_view
- - - - - 6b2aa24d by Philipp Hörist at 2018-09-21T21:55:57Z Fix rest of mypy errors
- This allows us to run mypy on the full gajim folder
- - - - - 0f730d19 by Philipp Hörist at 2018-09-21T21:56:56Z Update CI
- Run mypy on the full gajim folder
- - - - -
24 changed files:
- .gitlab-ci.yml - gajim/atom_window.py - gajim/chat_control.py - gajim/common/app.py - gajim/common/config.py - gajim/common/const.py - gajim/common/file_props.py - gajim/common/jingle_content.py - gajim/common/jingle_transport.py - gajim/common/passwords.py - gajim/common/pep.py - gajim/common/rst_xhtml_generator.py - gajim/common/socks5.py - gajim/common/types.py - gajim/common/zeroconf/client_zeroconf.py - gajim/common/zeroconf/zeroconf.py - + gajim/dev/__init__.py - gajim/dev/ipython_view.py - gajim/dialogs.py - gajim/gtk/single_message.py - gajim/gtkgui_helpers.py - gajim/roster_window.py - mypy.ini - scripts/dev/pre-push-tests.sh
Changes:
===================================== .gitlab-ci.yml ===================================== @@ -14,7 +14,7 @@ run-test: run-mypy: stage: test script: - - mypy -p gajim.common.modules --follow-imports=skip + - mypy gajim
run-pylint: stage: test
===================================== gajim/atom_window.py ===================================== @@ -17,6 +17,9 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import List # pylint: disable=unused-import +from typing import Any # pylint: disable=unused-import + from gi.repository import Gdk from gi.repository import GLib
@@ -26,7 +29,7 @@ from gajim.common import i18n
class AtomWindow: window = None - entries = [] + entries = [] # type: List[Any]
@classmethod def newAtomEntry(cls, entry):
===================================== gajim/chat_control.py ===================================== @@ -23,12 +23,21 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import ClassVar # pylint: disable=unused-import +from typing import Type # pylint: disable=unused-import + import os import time + from gi.repository import Gtk from gi.repository import Gio from gi.repository import Pango from gi.repository import GLib +from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC +from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO +from nbxmpp.protocol import NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER_5 +from nbxmpp.protocol import NS_CHATSTATES + from gajim import gtkgui_helpers from gajim import gui_menu_builder from gajim import message_control @@ -41,14 +50,11 @@ from gajim.common import helpers from gajim.common import ged from gajim.common import i18n from gajim.common.contacts import GC_Contact -from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC -from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO -from nbxmpp.protocol import NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER_5 -from nbxmpp.protocol import NS_CHATSTATES from gajim.common.connection_handlers_events import MessageOutgoingEvent from gajim.common.const import AvatarSize, KindConstant
from gajim.command_system.implementation.hosts import ChatCommands +from gajim.command_system.framework import CommandHost # pylint: disable=unused-import from gajim.chat_control_base import ChatControlBase
################################################################################ @@ -69,7 +75,7 @@ class ChatControl(ChatControlBase):
# Set a command host to bound to. Every command given through a chat will be # processed with this command host. - COMMAND_HOST = ChatCommands + COMMAND_HOST = ChatCommands # type: ClassVar[Type[CommandHost]]
def __init__(self, parent_win, contact, acct, session, resource=None): ChatControlBase.__init__(self, self.TYPE_ID, parent_win,
===================================== gajim/common/app.py ===================================== @@ -24,8 +24,11 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import Any # pylint: disable=unused-import from typing import Dict # pylint: disable=unused-import from typing import List # pylint: disable=unused-import +from typing import Optional # pylint: disable=unused-import +from typing import cast
import os import sys @@ -44,21 +47,25 @@ from gajim.common import ged as ged_module from gajim.common.contacts import LegacyContactsAPI from gajim.common.events import Events from gajim.common.css_config import CSSConfig +from gajim.common.types import NetworkEventsControllerT # pylint: disable=unused-import +from gajim.common.types import InterfaceT # pylint: disable=unused-import +from gajim.common.types import LoggerT # pylint: disable=unused-import +from gajim.common.types import ConnectionT # pylint: disable=unused-import
-interface = None # type: gajim.interface.Interface +interface = cast(InterfaceT, None) thread_interface = lambda *args: None # Interface to run a thread and then a callback config = c_config.Config() version = gajim.__version__ -connections = {} # 'account name': 'account (connection.Connection) instance' -avatar_cache = {} +connections = {} # type: Dict[str, ConnectionT] +avatar_cache = {} # type: Dict[str, Dict[str, Any]] ipython_window = None app = None # Gtk.Application
ged = ged_module.GlobalEventsDispatcher() # Global Events Dispatcher -nec = None # type: gajim.common.nec.NetworkEventsController +nec = cast(NetworkEventsControllerT, None) plugin_manager = None # Plugins Manager
-logger = None # type: gajim.common.logger.Logger +logger = cast(LoggerT, None)
# For backwards compatibility needed # some plugins use that @@ -113,7 +120,7 @@ nicks = {} # type: Dict[str, str] # to something else than offline # can also contain account/transport_jid to block notifications for contacts # from this transport -block_signed_in_notifications = {} +block_signed_in_notifications = {} # type: Dict[str, bool]
# type of each connection (ssl, tls, tcp, ...) con_types = {} # type: Dict[str, Optional[str]] @@ -153,10 +160,10 @@ gajim_common_features = [nbxmpp.NS_BYTESTREAM, nbxmpp.NS_SI, nbxmpp.NS_FILE, nbxmpp.NS_EME, 'urn:xmpp:avatar:metadata+notify']
# Optional features gajim supports per account -gajim_optional_features = {} +gajim_optional_features = {} # type: Dict[str, List[str]]
# Capabilities hash per account -caps_hash = {} +caps_hash = {} # type: Dict[str, List[str]]
_dependencies = { 'PYTHON-DBUS': False,
===================================== gajim/common/config.py ===================================== @@ -27,6 +27,11 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import Any # pylint: disable=unused-import +from typing import Dict # pylint: disable=unused-import +from typing import List # pylint: disable=unused-import +from typing import Tuple # pylint: disable=unused-import + import re from enum import IntEnum, unique
@@ -287,7 +292,7 @@ class Config: 'use_keyring': [opt_bool, True, _('If true, Gajim will use the Systems Keyring to store account passwords.')], 'pgp_encoding': [opt_str, '', _('Sets the encoding used by python-gnupg'), True], 'remote_commands': [opt_bool, False, _('If true, Gajim will execute XEP-0146 Commands.')], - }, {}) + }, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
__options_per_key = { 'accounts': ({ @@ -436,7 +441,7 @@ class Config: 'plugins': ({ 'active': [opt_bool, False, _('State whether plugins should be activated on startup (this is saved on Gajim exit). This option SHOULD NOT be used to (de)activate plug-ins. Use GUI instead.')], }, {}), - } + } # type: Dict[str, Tuple[Dict[str, List[Any]], Dict[Any, Any]]]
statusmsg_default = { _('Sleeping'): ['ZZZZzzzzzZZZZZ', 'inactive', 'sleeping', '', 'sleepy', ''],
===================================== gajim/common/const.py ===================================== @@ -4,10 +4,10 @@ from collections import namedtuple from gajim.common.i18n import _
Option = namedtuple('Option', 'kind label type value name callback data desc enabledif props') -Option.__new__.__defaults__ = (None,) * len(Option._fields) +Option.__new__.__defaults__ = (None,) * len(Option._fields) # type: ignore
DialogButton = namedtuple('DialogButton', 'text callback action') -DialogButton.__new__.__defaults__ = (None, None) +DialogButton.__new__.__defaults__ = (None, None) # type: ignore
@unique
===================================== gajim/common/file_props.py ===================================== @@ -17,8 +17,14 @@ Exception: this class should not be instatiated True """
+from typing import Any # pylint: disable=unused-import +from typing import ClassVar # pylint: disable=unused-import +from typing import Dict # pylint: disable=unused-import +from typing import Tuple # pylint: disable=unused-import + + class FilesProp: - _files_props = {} + _files_props = {} # type: ClassVar[Dict[Tuple[str, str], Any]]
def __init__(self): raise Exception('this class should not be instantiated')
===================================== gajim/common/jingle_content.py ===================================== @@ -16,14 +16,19 @@ Handles Jingle contents (XEP 0166) """
+from typing import Any # pylint: disable=unused-import +from typing import Dict # pylint: disable=unused-import + import os + +import nbxmpp + from gajim.common import app from gajim.common import configpaths -import nbxmpp from gajim.common.jingle_xtls import SELF_SIGNED_CERTIFICATE from gajim.common.jingle_xtls import load_cert_file
-contents = {} +contents = {} # type: Dict[str, Any]
def get_jingle_content(node): namespace = node.getNamespace()
===================================== gajim/common/jingle_transport.py ===================================== @@ -16,16 +16,21 @@ Handles Jingle Transports (currently only ICE-UDP) """
+from typing import Any # pylint: disable=unused-import +from typing import Dict # pylint: disable=unused-import + import logging import socket from enum import IntEnum, unique + import nbxmpp + from gajim.common import app
log = logging.getLogger('gajim.c.jingle_transport')
-transports = {} +transports = {} # type: Dict[str, Any]
def get_jingle_transport(node): namespace = node.getNamespace()
===================================== gajim/common/passwords.py ===================================== @@ -28,10 +28,12 @@ __all__ = ['get_password', 'save_password']
log = logging.getLogger('gajim.password')
-keyring = None + try: import keyring + KEYRING_AVAILABLE = True except ImportError: + KEYRING_AVAILABLE = False log.debug('python-keyring missing, falling back to plaintext storage')
@@ -83,7 +85,7 @@ class PasswordStorageManager(PasswordStorage): """ # TODO: handle disappearing backends
- if app.config.get('use_keyring') and keyring: + if app.config.get('use_keyring') and KEYRING_AVAILABLE: self.secret = SecretPasswordStorage()
def get_password(self, account_name):
===================================== gajim/common/pep.py ===================================== @@ -19,11 +19,14 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import Any # pylint: disable=unused-import +from typing import List # pylint: disable=unused-import + import logging -log = logging.getLogger('gajim.c.pep')
from gajim.common import app
+log = logging.getLogger('gajim.c.pep')
class AbstractPEP:
@@ -75,4 +78,4 @@ class AbstractPEP: pass
-SUPPORTED_PERSONAL_USER_EVENTS = [] +SUPPORTED_PERSONAL_USER_EVENTS = [] # type: List[Any]
===================================== gajim/common/rst_xhtml_generator.py ===================================== @@ -18,11 +18,11 @@ # along with Gajim. If not, see http://www.gnu.org/licenses/.
try: - from docutils import io + from docutils import io # type: ignore from docutils.core import Publisher from docutils.parsers.rst import roles - from docutils import nodes, utils - from docutils.parsers.rst.roles import set_classes + from docutils import nodes, utils # type: ignore + from docutils.parsers.rst.roles import set_classes # type: ignore except ImportError: print("Requires docutils 0.4 for set_classes to be available") def create_xhtml(text):
===================================== gajim/common/socks5.py ===================================== @@ -799,7 +799,7 @@ class Socks5: return self.file_props.received_len return None
- def disconnect(self): + def disconnect(self, *args, **kwargs): """ Close open descriptors and remover socket descr. from idleque """
===================================== gajim/common/types.py ===================================== @@ -33,6 +33,15 @@ if TYPE_CHECKING: from gajim.common.contacts import Contact from gajim.common.contacts import GC_Contact from gajim.common.nec import NetworkEvent + from gajim.common.nec import NetworkEventsController + from gajim.common.logger import Logger + + from gajim.gui_interface import Interface + + +NetworkEventsControllerT = Union['NetworkEventsController'] +InterfaceT = Union['Interface'] +LoggerT = Union['Logger']
ConnectionT = Union['Connection', 'ConnectionZeroconf'] ContactT = Union['Contact', 'GC_Contact']
===================================== gajim/common/zeroconf/client_zeroconf.py ===================================== @@ -19,6 +19,7 @@ from gajim.common import app import nbxmpp from nbxmpp.idlequeue import IdleObject from nbxmpp import dispatcher_nb, simplexml +from nbxmpp.plugin import PlugIn from nbxmpp.plugin import * from nbxmpp.transports_nb import DATA_RECEIVED, DATA_SENT, DATA_ERROR from gajim.common.zeroconf import zeroconf
===================================== gajim/common/zeroconf/zeroconf.py ===================================== @@ -14,8 +14,11 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import Any # pylint: disable=unused-import + from enum import IntEnum, unique
+ @unique class Constant(IntEnum): NAME = 0 @@ -54,7 +57,7 @@ def test_zeroconf():
if test_avahi(): from gajim.common.zeroconf import zeroconf_avahi - Zeroconf = zeroconf_avahi.Zeroconf + Zeroconf = zeroconf_avahi.Zeroconf # type: Any elif test_bonjour(): from gajim.common.zeroconf import zeroconf_bonjour Zeroconf = zeroconf_bonjour.Zeroconf
===================================== gajim/dev/__init__.py =====================================
===================================== gajim/dev/ipython_view.py ===================================== @@ -40,17 +40,17 @@ available under the terms of the BSD which accompanies this distribution, and is available at U{http://www.opensource.org/licenses/bsd-license.php%7D """
+import re +import sys +import os +from io import StringIO from functools import reduce
from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject from gi.repository import GLib -import re -import sys -import os from gi.repository import Pango -from io import StringIO
try: import IPython @@ -92,8 +92,8 @@ class IterableIPShell: @ivar complete_sep: Seperation delimeters for completion function. @type complete_sep: _sre.SRE_Pattern """ - def __init__(self,argv=[],user_ns=None,user_global_ns=None, cin=None, - cout=None,cerr=None, input_func=None): + def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None, + cout=None, cerr=None, input_func=None): """ @param argv: Command line options for IPython @type argv: list @@ -110,6 +110,9 @@ class IterableIPShell: @param input_func: Replacement for builtin raw_input() @type input_func: function """ + if argv is None: + argv = [] + io = IPython.utils.io if input_func: if IPython.version_info[0] >= 1: @@ -161,9 +164,9 @@ class IterableIPShell: sys.excepthook = excepthook self.iter_more = 0 self.history_level = 0 - self.complete_sep = re.compile('[\s{}[]()]') - self.updateNamespace({'exit':lambda:None}) - self.updateNamespace({'quit':lambda:None}) + self.complete_sep = re.compile(r'[\s{}[]()]') + self.updateNamespace({'exit':lambda: None}) + self.updateNamespace({'quit':lambda: None}) #self.IP.readline_startup_hook(self.IP.pre_readline) # Workaround for updating namespace with sys.modules # @@ -173,7 +176,7 @@ class IterableIPShell: ''' Update self.IP namespace for autocompletion with sys.modules ''' - for k,v in sys.modules.items(): + for k, v in sys.modules.items(): if not '.' in k: self.IP.user_ns.update({k:v})
@@ -315,7 +318,7 @@ class IterableIPShell: possibilities = self.IP.complete(split_line[-1]) else: completed = line - possibilities = ['',[]] + possibilities = ['', []] if possibilities: def _commonPrefix(str1, str2): ''' @@ -361,14 +364,14 @@ class ConsoleView(Gtk.TextView): @type line_start: Gtk.TextMark """
- ANSI_COLORS = {'0;30': 'Black', '0;31': 'Red', - '0;32': 'Green', '0;33': 'Brown', - '0;34': 'Blue', '0;35': 'Purple', - '0;36': 'Cyan', '0;37': 'LightGray', - '1;30': 'DarkGray', '1;31': 'DarkRed', - '1;32': 'SeaGreen', '1;33': 'Yellow', - '1;34': 'LightBlue', '1;35': 'MediumPurple', - '1;36': 'LightCyan', '1;37': 'White'} + ANSI_COLORS = {'0;30': 'Black', '0;31': 'Red', + '0;32': 'Green', '0;33': 'Brown', + '0;34': 'Blue', '0;35': 'Purple', + '0;36': 'Cyan', '0;37': 'LightGray', + '1;30': 'DarkGray', '1;31': 'DarkRed', + '1;32': 'SeaGreen', '1;33': 'Yellow', + '1;34': 'LightBlue', '1;35': 'MediumPurple', + '1;36': 'LightCyan', '1;37': 'White'}
def __init__(self): """ @@ -387,7 +390,7 @@ class ConsoleView(Gtk.TextView): weight=700) self.text_buffer.create_tag('0') self.text_buffer.create_tag('notouch', editable=False) - self.color_pat = re.compile('\x01?\x1b[(.*?)m\x02?') + self.color_pat = re.compile(r'\x01?\x1b[(.*?)m\x02?') if HAS_IPYTHON5: self.style_dict = { Token.Prompt: '0;32', @@ -401,7 +404,7 @@ class ConsoleView(Gtk.TextView): self.connect('key-press-event', self.onKeyPress)
def write(self, text, editable=False): - if type(text) == str: + if isinstance(text, str): GLib.idle_add(self._write, text, editable) elif IPython.version_info[0] >= 5: GLib.idle_add(self._write5, text, editable) @@ -422,7 +425,7 @@ class ConsoleView(Gtk.TextView): for token, segment in text: tag = self.style_dict[token] self.text_buffer.insert_with_tags_by_name(self.text_buffer.get_end_iter(), - segment, tag) + segment, tag) if not editable: self.text_buffer.apply_tag_by_name('notouch', self.text_buffer.get_iter_at_mark(start_mark), @@ -439,7 +442,7 @@ class ConsoleView(Gtk.TextView): @param editable: If true, added text is editable. @type editable: boolean """ - if type(text) == list and IPython.version_info[0] >= 5: + if isinstance(text, list) and IPython.version_info[0] >= 5: self._write5(text, editable) return segments = self.color_pat.split(text) @@ -454,7 +457,7 @@ class ConsoleView(Gtk.TextView): for tag in ansi_tags: i = segments.index(tag) self.text_buffer.insert_with_tags_by_name(self.text_buffer.get_end_iter(), - segments[i+1], str(tag)) + segments[i+1], str(tag)) segments.pop(i) if not editable: self.text_buffer.apply_tag_by_name('notouch', @@ -501,8 +504,8 @@ class ConsoleView(Gtk.TextView): @rtype: string """ rv = self.text_buffer.get_slice( - self.text_buffer.get_iter_at_mark(self.line_start), - self.text_buffer.get_end_iter(), False) + self.text_buffer.get_iter_at_mark(self.line_start), + self.text_buffer.get_end_iter(), False) return rv
def showReturned(self, text): @@ -518,9 +521,9 @@ class ConsoleView(Gtk.TextView): iter_ = self.text_buffer.get_iter_at_mark(self.line_start) iter_.forward_to_line_end() self.text_buffer.apply_tag_by_name( - 'notouch', - self.text_buffer.get_iter_at_mark(self.line_start), - iter_) + 'notouch', + self.text_buffer.get_iter_at_mark(self.line_start), + iter_) self._write('\n'+text) if text: self._write('\n') @@ -532,7 +535,7 @@ class ConsoleView(Gtk.TextView): indentation = self.IP.input_splitter.indent_spaces * ' ' self.text_buffer.insert_at_cursor(indentation)
- def onKeyPress(self, widget, event): + def onKeyPress(self, _widget, event): """ Key press callback used for correcting behavior for console-like interfaces. For example 'home' should go to prompt, not to beginning of @@ -555,10 +558,11 @@ class ConsoleView(Gtk.TextView): if event.get_state() == 0: self.text_buffer.place_cursor(start_iter) return True - elif event.get_state() == Gdk.ModifierType.SHIFT_MASK: + if event.get_state() == Gdk.ModifierType.SHIFT_MASK: self.text_buffer.move_mark(insert_mark, start_iter) return True - elif event.keyval == Gdk.KEY_Left: + + if event.keyval == Gdk.KEY_Left: insert_iter.backward_cursor_position() if not insert_iter.editable(True): return True @@ -611,7 +615,7 @@ class IPythonView(ConsoleView, IterableIPShell): # IPython 5.0 calls prompt_for_code instead of raw_input return self.raw_input(self)
- def raw_input(self, prompt=''): + def raw_input(self, _prompt=''): """ Custom raw_input() replacement. Get's current line from console buffer
@@ -643,16 +647,16 @@ class IPythonView(ConsoleView, IterableIPShell): self.interrupt = True self._processLine() return True - elif event.keyval == Gdk.KEY_Return: + if event.keyval == Gdk.KEY_Return: self._processLine() return True - elif event.keyval == Gdk.KEY_Up: + if event.keyval == Gdk.KEY_Up: self.changeLine(self.historyBack()) return True - elif event.keyval == Gdk.KEY_Down: + if event.keyval == Gdk.KEY_Down: self.changeLine(self.historyForward()) return True - elif event.keyval == Gdk.KEY_Tab: + if event.keyval == Gdk.KEY_Tab: if not self.getCurrentLine().strip(): return False completed, possibilities = self.complete(self.getCurrentLine()) @@ -672,7 +676,8 @@ class IPythonView(ConsoleView, IterableIPShell): self.history_pos = 0 self.execute() rv = self.cout.getvalue() - if rv: rv = rv.strip('\n') + if rv: + rv = rv.strip('\n') self.showReturned(rv) self.cout.truncate(0) self.cout.seek(0)
===================================== gajim/dialogs.py ===================================== @@ -25,18 +25,22 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
-from gi.repository import Gtk -from gi.repository import Gdk -from gi.repository import GLib +from typing import Dict # pylint: disable=unused-import +from typing import List # pylint: disable=unused-import +from typing import Tuple # pylint: disable=unused-import
import os import logging +from random import randrange + +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GLib
from gajim import gtkgui_helpers from gajim import vcard from gajim import dataforms_widget
-from random import randrange from gajim.common import ged from gajim.common.i18n import _ from gajim.common.const import ACTIVITIES @@ -1363,7 +1367,7 @@ class ProgressDialog:
class TransformChatToMUC: # Keep a reference on windows so garbage collector don't restroy them - instances = [] + instances = [] # type: List[TransformChatToMUC] def __init__(self, account, jids, preselected=None): """ This window is used to trasform a one-to-one chat to a MUC. We do 2 @@ -1584,7 +1588,7 @@ class ResourceConflictDialog(TimeoutDialog, InputDialog):
class VoIPCallReceivedDialog: - instances = {} + instances = {} # type: Dict[Tuple[str, str], VoIPCallReceivedDialog] def __init__(self, account, contact_jid, sid, content_types): self.instances[(contact_jid, sid)] = self self.account = account
===================================== gajim/gtk/single_message.py ===================================== @@ -12,6 +12,8 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+from typing import List # pylint: disable=unused-import + from gi.repository import Gdk from gi.repository import GLib
@@ -40,7 +42,7 @@ class SingleMessageWindow: action argument which can be 'send' or 'receive' """ # Keep a reference on windows so garbage collector don't restroy them - instances = [] + instances = [] # type: List[SingleMessageWindow] def __init__(self, account, to='', action='', from_whom='', subject='', message='', resource='', session=None, form_node=None): self.instances.append(self)
===================================== gajim/gtkgui_helpers.py ===================================== @@ -23,32 +23,34 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see http://www.gnu.org/licenses/.
+import cairo +import os +import sys +import math +import logging +from io import BytesIO +import xml.etree.ElementTree as ET import xml.sax.saxutils +from xml.sax import ContentHandler # type: ignore + from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GdkPixbuf from gi.repository import GLib from gi.repository import Pango -import cairo -import os -import sys -import math -import xml.etree.ElementTree as ET
try: from PIL import Image except Exception: pass -from io import BytesIO - -import logging -log = logging.getLogger('gajim.gtkgui_helpers')
from gajim.common import i18n from gajim.common import app from gajim.common import configpaths from gajim.common.const import PEPEventType, ACTIVITIES, MOODS
+log = logging.getLogger('gajim.gtkgui_helpers') + gtk_icon_theme = Gtk.IconTheme.get_default() gtk_icon_theme.append_search_path(configpaths.get('ICONS'))
@@ -234,9 +236,9 @@ def scroll_to_end(widget): return False
-class ServersXMLHandler(xml.sax.ContentHandler): +class ServersXMLHandler(ContentHandler): def __init__(self): - xml.sax.ContentHandler.__init__(self) + ContentHandler.__init__(self) self.servers = []
def startElement(self, name, attributes):
===================================== gajim/roster_window.py ===================================== @@ -5643,7 +5643,7 @@ class RosterWindow: ### ################################################################################
- def __init__(self, application: Gtk.Application): + def __init__(self, application): self.application = application self.filtering = False self.starting = False
===================================== mypy.ini ===================================== @@ -1,5 +1,6 @@ [mypy] python_version = 3.5 +warn_unused_configs = True disallow_incomplete_defs = True
[mypy-nbxmpp.*] @@ -61,3 +62,12 @@ ignore_missing_imports = True
[mypy-docutils.*] ignore_missing_imports = True + +[mypy-IPython.*] +ignore_missing_imports = True + +[mypy-traitlets.*] +ignore_missing_imports = True + +[mypy-pygments.*] +ignore_missing_imports = True \ No newline at end of file
===================================== scripts/dev/pre-push-tests.sh ===================================== @@ -1,4 +1,4 @@ -mypy -p gajim.common.modules --follow-imports=skip +mypy gajim pylint --jobs=2 --disable=C0103,C0302,C0330,C0411,C0412,C0413,E0203,E0401,E0611,E0710,E0712,E1101,E1102,E1128,E1133,E1136,R0201,R0901,R0904,R0913,R0916,R1702,R1706,R1711,R1716,W0143,W0201,W0212,W0221,W0223,W0311,W0401,W0603,W0613,W0614 gajim
# C0103 invalid-name
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/74b66837fa00dd9a196f3aaa0dc2fbfc6b...