From f832900d2b4695ab6614b0e7eaf49efc173cbe89 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Wed, 22 Aug 2012 12:55:57 +0200
Subject: [PATCH] coding standards

---
 src/adhoc_commands.py                    |   2 +-
 src/common/connection_handlers_events.py |   4 +-
 src/common/dataforms.py                  |   8 +-
 src/common/jingle_ft.py                  |   8 +-
 src/common/jingle_ftstates.py            |   4 +-
 src/common/jingle_transport.py           |   2 +-
 src/common/pep.py                        |  26 ++---
 src/common/resolver.py                   |  10 +-
 src/common/socks5.py                     | 123 +++++++++--------------
 src/common/stanza_session.py             |   2 +-
 src/config.py                            |   2 +-
 src/dataforms_widget.py                  |  26 ++---
 src/groupchat_control.py                 |   2 +-
 src/search_window.py                     |   2 +-
 src/statusicon.py                        |   2 +-
 test/lib/gajim_mocks.py                  |   2 +-
 16 files changed, 96 insertions(+), 129 deletions(-)

diff --git a/src/adhoc_commands.py b/src/adhoc_commands.py
index 2f556fcc00..bc947d49d4 100644
--- a/src/adhoc_commands.py
+++ b/src/adhoc_commands.py
@@ -371,7 +371,7 @@ class CommandWindow:
                     _('The form is not filled correctly.'))
                 self.data_form_widget.set_sensitive(True)
                 return
-            self.data_form_widget.data_form.type = 'submit'
+            self.data_form_widget.data_form.type_ = 'submit'
         else:
             self.data_form_widget.hide()
 
diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py
index a30c9f1f81..a855b59789 100644
--- a/src/common/connection_handlers_events.py
+++ b/src/common/connection_handlers_events.py
@@ -1683,7 +1683,7 @@ class PEPReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
             pep = pep_class.get_tag_as_PEP(self.fjid, self.conn.name,
                 self.event_tag)
             if pep:
-                self.pep_type = pep.type
+                self.pep_type = pep.type_
                 return True
 
         items = self.event_tag.getTag('items')
@@ -2007,7 +2007,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
                 return
             self.dataform = dataforms.ExtendForm(node=form_tag)
             for f in self.dataform.iter_fields():
-                if f.var == 'stream-method' and f.type == 'list-single':
+                if f.var == 'stream-method' and f.type_ == 'list-single':
                     values = [o[1] for o in f.options]
                     self.file_props.stream_methods = ' '.join(values)
                     if xmpp.NS_BYTESTREAM in values or xmpp.NS_IBB in values:
diff --git a/src/common/dataforms.py b/src/common/dataforms.py
index ca7ae513dc..20d6b23ac4 100644
--- a/src/common/dataforms.py
+++ b/src/common/dataforms.py
@@ -120,7 +120,7 @@ class DataField(ExtendedNode):
         if extend is None:
             ExtendedNode.__init__(self, 'field')
 
-            self.type = typ
+            self.type_ = typ
             self.var = var
             if value is not None:
                 self.value = value
@@ -248,7 +248,7 @@ class DataField(ExtendedNode):
                 self.delChild(t)
 
         return locals()
-    
+
     def is_valid(self):
         return True
 
@@ -463,7 +463,7 @@ class ListMultiField(ListField):
     def iter_values(self):
         for element in self.getTags('value'):
             yield element.getData()
-            
+
     def is_valid(self):
         if not self.required:
             return True
@@ -577,7 +577,7 @@ class DataRecord(ExtendedNode):
 
     def __getitem__(self, item):
         return self.vars[item]
-    
+
     def is_valid(self):
         for f in self.iter_fields():
             if not f.is_valid():
diff --git a/src/common/jingle_ft.py b/src/common/jingle_ft.py
index 0f6973bf11..bfb84fb6fe 100644
--- a/src/common/jingle_ft.py
+++ b/src/common/jingle_ft.py
@@ -186,7 +186,7 @@ class JingleFileTransfer(JingleContent):
         fingerprint = None
         if self.use_security:
             fingerprint = 'client'
-        if self.transport.type == TransportType.SOCKS5:
+        if self.transport.type_ == TransportType.SOCKS5:
             gajim.socks5queue.connect_to_hosts(self.session.connection.name,
                 self.file_props.sid, self.on_connect,
                 self._on_connect_error, fingerprint=fingerprint,
@@ -272,7 +272,7 @@ class JingleFileTransfer(JingleContent):
     action=None):
         # Sets up a few transport specific things for the file transfer
 
-        if self.transport.type == TransportType.IBB:
+        if self.transport.type_ == TransportType.IBB:
             # No action required, just set the state to transfering
             self.state = STATE_TRANSFERING
 
@@ -323,11 +323,11 @@ class JingleFileTransfer(JingleContent):
         if self.weinitiate:
             listener = gajim.socks5queue.start_listener(port, sha_str,
                 self._store_socks5_sid, self.file_props,
-                fingerprint=fingerprint, type='sender')
+                fingerprint=fingerprint, typ='sender')
         else:
             listener = gajim.socks5queue.start_listener(port, sha_str,
                 self._store_socks5_sid, self.file_props,
-                fingerprint=fingerprint, type='receiver')
+                fingerprint=fingerprint, typ='receiver')
 
         if not listener:
             # send error message, notify the user
diff --git a/src/common/jingle_ftstates.py b/src/common/jingle_ftstates.py
index 52d4b7d44e..9d7e8e1d7f 100644
--- a/src/common/jingle_ftstates.py
+++ b/src/common/jingle_ftstates.py
@@ -219,8 +219,8 @@ class StateTransfering(JingleFileTransferStates):
                 self.jft.session.connection.name, mode)
 
     def action(self, args=None):
-        if self.jft.transport.type == TransportType.IBB:
+        if self.jft.transport.type_ == TransportType.IBB:
             self.__start_IBB_transfer(self.jft.session.connection)
 
-        elif self.jft.transport.type == TransportType.SOCKS5:
+        elif self.jft.transport.type_ == TransportType.SOCKS5:
             self.__start_SOCK5_transfer()
diff --git a/src/common/jingle_transport.py b/src/common/jingle_transport.py
index fdf74e0d94..c2fbbdb953 100644
--- a/src/common/jingle_transport.py
+++ b/src/common/jingle_transport.py
@@ -47,7 +47,7 @@ class JingleTransport(object):
     """
 
     def __init__(self, type_):
-        self.type = type_
+        self.type_ = type_
         self.candidates = []
         self.remote_candidates = []
 
diff --git a/src/common/pep.py b/src/common/pep.py
index be94e92350..87283026e7 100644
--- a/src/common/pep.py
+++ b/src/common/pep.py
@@ -211,14 +211,14 @@ import gtkgui_helpers
 
 class AbstractPEP(object):
 
-    type = ''
+    type_ = ''
     namespace = ''
 
     @classmethod
     def get_tag_as_PEP(cls, jid, account, event_tag):
         items = event_tag.getTag('items', {'node': cls.namespace})
         if items:
-            log.debug("Received PEP 'user %s' from %s" % (cls.type, jid))
+            log.debug("Received PEP 'user %s' from %s" % (cls.type_, jid))
             return cls(jid, account, items)
         else:
             return None
@@ -237,18 +237,18 @@ class AbstractPEP(object):
     def _update_contacts(self, jid, account):
         for contact in gajim.contacts.get_contacts(account, jid):
             if self._retracted:
-                if self.type in contact.pep:
-                    del contact.pep[self.type]
+                if self.type_ in contact.pep:
+                    del contact.pep[self.type_]
             else:
-                contact.pep[self.type] = self
+                contact.pep[self.type_] = self
 
     def _update_account(self, account):
         acc = gajim.connections[account]
         if self._retracted:
-            if self.type in acc.pep:
-                del acc.pep[self.type]
+            if self.type_ in acc.pep:
+                del acc.pep[self.type_]
         else:
-            acc.pep[self.type] = self
+            acc.pep[self.type_] = self
 
     def asPixbufIcon(self):
         '''SHOULD be implemented by subclasses'''
@@ -262,7 +262,7 @@ class AbstractPEP(object):
 class UserMoodPEP(AbstractPEP):
     '''XEP-0107: User Mood'''
 
-    type = 'mood'
+    type_ = 'mood'
     namespace = xmpp.NS_MOOD
 
     def _extract_info(self, items):
@@ -308,7 +308,7 @@ class UserMoodPEP(AbstractPEP):
 class UserTunePEP(AbstractPEP):
     '''XEP-0118: User Tune'''
 
-    type = 'tune'
+    type_ = 'tune'
     namespace = xmpp.NS_TUNE
 
     def _extract_info(self, items):
@@ -354,7 +354,7 @@ class UserTunePEP(AbstractPEP):
 class UserActivityPEP(AbstractPEP):
     '''XEP-0108: User Activity'''
 
-    type = 'activity'
+    type_ = 'activity'
     namespace = xmpp.NS_ACTIVITY
 
     def _extract_info(self, items):
@@ -420,7 +420,7 @@ class UserActivityPEP(AbstractPEP):
 class UserNicknamePEP(AbstractPEP):
     '''XEP-0172: User Nickname'''
 
-    type = 'nickname'
+    type_ = 'nickname'
     namespace = xmpp.NS_NICK
 
     def _extract_info(self, items):
@@ -449,7 +449,7 @@ class UserNicknamePEP(AbstractPEP):
 class UserLocationPEP(AbstractPEP):
     '''XEP-0080: User Location'''
 
-    type = 'location'
+    type_ = 'location'
     namespace = xmpp.NS_LOCATION
 
     def _extract_info(self, items):
diff --git a/src/common/resolver.py b/src/common/resolver.py
index 493d8d122d..d3306c22d7 100644
--- a/src/common/resolver.py
+++ b/src/common/resolver.py
@@ -295,23 +295,23 @@ class NsLookup(IdleCommand):
         IdleCommand.__init__(self, on_result)
         self.commandtimeout = 10
         self.host = host.lower()
-        self.type = type.lower()
+        self.type_ = type.lower()
         if not host_pattern.match(self.host):
             # invalid host name
             log.error('Invalid host: %s' % self.host)
             self.canexecute = False
             return
-        if not ns_type_pattern.match(self.type):
-            log.error('Invalid querytype: %s' % self.type)
+        if not ns_type_pattern.match(self.type_):
+            log.error('Invalid querytype: %s' % self.type_)
             self.canexecute = False
             return
 
     def _compose_command_args(self):
-        return ['nslookup', '-type=' + self.type, self.host]
+        return ['nslookup', '-type=' + self.type_, self.host]
 
     def _return_result(self):
         if self.result_handler:
-            self.result_handler(self.host, self.type, self.result)
+            self.result_handler(self.host, self.type_, self.result)
         self.result_handler = None
 
 # below lines is on how to use API and assist in testing
diff --git a/src/common/socks5.py b/src/common/socks5.py
index 3ff7868029..bcecc2af24 100644
--- a/src/common/socks5.py
+++ b/src/common/socks5.py
@@ -82,18 +82,18 @@ class SocksQueue:
         self.on_success = {} # {id: cb}
         self.on_failure = {} # {id: cb}
 
-    def start_listener(self, port, sha_str, sha_handler, file_props, fingerprint=None,
-    type='sender'):
+    def start_listener(self, port, sha_str, sha_handler, file_props,
+    fingerprint=None, typ='sender'):
         """
         Start waiting for incomming connections on (host, port) and do a socks5
         authentication using sid for generated SHA
         """
         sid = file_props.sid
-        self.type = type # It says whether we are sending or receiving
+        self.type_ = typ # It says whether we are sending or receiving
         self.sha_handlers[sha_str] = (sha_handler, sid)
         if self.listener is None or self.listener.connections == []:
             self.listener = Socks5Listener(self.idlequeue, port, file_props,
-                    fingerprint=fingerprint)
+                fingerprint=fingerprint)
             self.listener.queue = self
             self.listener.bind()
         else:
@@ -135,9 +135,9 @@ class SocksQueue:
             else:
                 fp = fingerprint
             if receiving:
-                self.type = 'receiver'
-                socks5obj = Socks5ReceiverClient(self.idlequeue, streamhost, sid,
-                     file_props, fingerprint=fp)
+                self.type_ = 'receiver'
+                socks5obj = Socks5ReceiverClient(self.idlequeue, streamhost,
+                    sid, file_props, fingerprint=fp)
                 self.add_sockobj(account, socks5obj)
             else:
                 if file_props.sha_str:
@@ -145,7 +145,7 @@ class SocksQueue:
                 else:
                     idx = self.idx
                     self.idx = self.idx + 1
-                self.type = 'sender'
+                self.type_ = 'sender'
                 if 'type' in streamhost and streamhost['type'] == 'proxy':
                     file_props.is_a_proxy = True
                     file_props.proxy_sender = streamhost['target']
@@ -155,7 +155,7 @@ class SocksQueue:
                     port=int(streamhost['port']),fingerprint=fp,
                     connected=False, file_props=file_props)
                 socks5obj.streamhost = streamhost
-                self.add_sockobj(account, socks5obj, type='sender')
+                self.add_sockobj(account, socks5obj, type_='sender')
 
             streamhost['idx'] = socks5obj.queue_idx
 
@@ -168,7 +168,7 @@ class SocksQueue:
             if host != streamhost and 'idx' in host:
                 if host['state'] == 1:
                     # remove current
-                    if self.type == 'sender':
+                    if self.type_ == 'sender':
                         self.remove_sender(streamhost['idx'], False)
                     else:
                         self.remove_receiver(streamhost['idx'])
@@ -176,7 +176,7 @@ class SocksQueue:
                 # set state -2, meaning that this streamhost is stopped,
                 # but it may be connectected later
                 if host['state'] >= 0:
-                    if self.type == 'sender':
+                    if self.type_ == 'sender':
                         self.remove_sender(host['idx'], False)
                     else:
                         self.remove_receiver(host['idx'])
@@ -206,8 +206,8 @@ class SocksQueue:
                 if host['state'] == -2:
                     host['state'] = 0
                     # FIXME: make the sender reconnect also
-                    client = Socks5ReceiverClient(self.idlequeue, host, host['sid'],
-                        file_props)
+                    client = Socks5ReceiverClient(self.idlequeue, host,
+                        host['sid'], file_props)
                     self.add_sockobj(client.account, client)
                     host['idx'] = client.queue_idx
             # we still have chances to connect
@@ -239,12 +239,12 @@ class SocksQueue:
             file_props.failure_cb(file_props.sid)
             file_props.failure_cb = None
 
-    def add_sockobj(self, account, sockobj, type='receiver'):
+    def add_sockobj(self, account, sockobj, type_='receiver'):
         """
         Add new file a sockobj type receiver or sender, and use it to connect
         to server
         """
-        if type == 'receiver':
+        if type_ == 'receiver':
             self._add(sockobj, self.readers, sockobj.file_props, self.idx)
         else:
             self._add(sockobj, self.senders, sockobj.file_props, self.idx)
@@ -311,7 +311,7 @@ class SocksQueue:
             if file_props.name in key and file_props.sid in key \
             and self.senders[key].mode == mode:
 
-                log.info("socks5: sending file")
+                log.info('socks5: sending file')
                 sender = self.senders[key]
                 file_props.streamhost_used = True
                 sender.account = account
@@ -324,7 +324,7 @@ class SocksQueue:
         fp = FilesProp.getFileProp(account, sid)
         if not fp:
             log.warning('trying to remove a file props that doesnt exist ' +
-                        'from account ' + str(account) + ' and sid ' + str(sid))
+                'from account ' + str(account) + ' and sid ' + str(sid))
             return
         if sid in self.on_success:
             del self.on_success[fp.sid]
@@ -347,7 +347,7 @@ class SocksQueue:
 
     def on_connection_accepted(self, sock, listener):
         sock_hash = sock.__hash__()
-        if self.type == 'sender' and \
+        if self.type_ == 'sender' and \
         not self.isHashInSockObjs(self.senders, sock_hash):
 
             sockobj =  Socks5SenderServer(self.idlequeue, sock_hash, self,
@@ -358,8 +358,8 @@ class SocksQueue:
             self.idlequeue.plug_idle(sockobj, False, True)
             self.connected += 1
 
-        if self.type == 'receiver' and \
-                    not self.isHashInSockObjs(self.readers, sock_hash):
+        if self.type_ == 'receiver' and \
+        not self.isHashInSockObjs(self.readers, sock_hash):
             sh = {}
             sh['host'] = sock[1][0]
             sh['port'] = sock[1][1]
@@ -376,7 +376,6 @@ class SocksQueue:
             sockobj.queue = self
             self.connected += 1
 
-
     def process_result(self, result, actor):
         """
         Take appropriate actions upon the result:
@@ -465,7 +464,7 @@ class Socks5:
         self.remaining_buff = ''
         self.file = None
         self.connected = False
-        self.type = ''
+        self.type_ = ''
         self.mode = ''
 
 
@@ -506,7 +505,6 @@ class Socks5:
 
     def do_connect(self):
         try:
-            #self._sock.setblocking(True)
             self._sock.connect(self._server)
             self._sock.setblocking(False)
             self._send=self._sock.send
@@ -552,7 +550,6 @@ class Socks5:
             else:
                 # stop transfer, there is no error code for this
                 self.pollend()
-
         else:
             if self.mode == 'client':
                 self.queue.reconnect_client(self, self.streamhost)
@@ -580,8 +577,8 @@ class Socks5:
 
     def get_fd(self):
         """
-        Test if file is already open and return its fd, or just open the file and
-        return the fd
+        Test if file is already open and return its fd, or just open the file
+        and return the fd
         """
         if self.file_props.fd:
             fd = self.file_props.fd
@@ -900,8 +897,8 @@ class Socks5:
             return hashlib.sha1('%s%s%s' % (self.sid,
                 self.file_props.proxy_sender,
                 self.file_props.proxy_receiver)).hexdigest()
-        return hashlib.sha1('%s%s%s' % (self.sid, self.initiator, self.target)).\
-                hexdigest()
+        return hashlib.sha1('%s%s%s' % (self.sid, self.initiator,
+            self.target)).hexdigest()
 
 
 class Socks5Sender(IdleObject):
@@ -911,21 +908,18 @@ class Socks5Sender(IdleObject):
 
     def __init__(self, idlequeue, sock_hash, parent, _sock, host=None,
     port=None, fingerprint = None, connected=True, file_props={}):
-
         self.fingerprint = fingerprint
         self.queue_idx = sock_hash
         self.queue = parent
         self.file_props = file_props
         self.proxy = False
 
-
         self._sock = _sock
 
-
         if _sock is not None:
             if self.fingerprint is not None:
                 self._sock = OpenSSL.SSL.Connection(
-                               jingle_xtls.get_context('server'), _sock)
+                    jingle_xtls.get_context('server'), _sock)
             else:
                 self._sock.setblocking(False)
 
@@ -947,7 +941,7 @@ class Socks5Sender(IdleObject):
         self.file_props.elapsed_time = 0
         self.file_props.last_time = self.idlequeue.current_time()
         self.file_props.received_len = 0
-        self.type = 'sender'
+        self.type_ = 'sender'
 
     def start_transfer(self):
         """
@@ -955,9 +949,7 @@ class Socks5Sender(IdleObject):
         """
         return self.write_next()
 
-
     def set_connection_sock(self, _sock):
-
         self._sock = _sock
 
         if self.fingerprint is not None:
@@ -1023,7 +1015,6 @@ class Socks5Receiver(IdleObject):
         self.file_props.stalled = False
         self.file_props.received_len = 0
 
-
     def receive_file(self):
         """
         Start receiving the file over verified connection
@@ -1077,9 +1068,7 @@ class Socks5Receiver(IdleObject):
 
 class Socks5Server(Socks5):
     def __init__(self, idlequeue, host, port, initiator, target, sid):
-
         Socks5.__init__(self, idlequeue, host, port, initiator, target, sid)
-
         self.mode = 'server'
 
     def main(self):
@@ -1103,7 +1092,6 @@ class Socks5Server(Socks5):
         self.idlequeue.plug_idle(self, True, False)
         return None
 
-
     def pollin(self):
         self.idlequeue.remove_timeout(self.fd)
         if self.connected:
@@ -1117,7 +1105,7 @@ class Socks5Server(Socks5):
 
                 elif self.state == 5:
                     self.state = 7
-                    if self.type == 'sender':
+                    if self.type_ == 'sender':
                         # We wait for the end of the negotiation to
                         # send the file
                         self.idlequeue.plug_idle(self, False, False)
@@ -1128,7 +1116,8 @@ class Socks5Server(Socks5):
 
                 elif self.state == 7:
                     if self.file_props.paused:
-                        self.file_props.continue_cb = self.continue_paused_transfer
+                        self.file_props.continue_cb = \
+                            self.continue_paused_transfer
                         self.idlequeue.plug_idle(self, False, False)
                         return
                     self.idlequeue.set_read_timeout(self.fd, STALLED_TIMEOUT)
@@ -1140,7 +1129,6 @@ class Socks5Server(Socks5):
         else:
             self.disconnect()
 
-
     def pollend(self):
         self.state = 8 # end connection
         self.disconnect()
@@ -1181,9 +1169,7 @@ class Socks5Server(Socks5):
 class Socks5Client(Socks5):
 
     def __init__(self, idlequeue, host, port, initiator, target, sid):
-
         Socks5.__init__(self, idlequeue, host, port, initiator, target, sid)
-
         self.mode = 'client'
 
     def main(self, timeout=0):
@@ -1226,9 +1212,8 @@ class Socks5Client(Socks5):
             if self.queue.on_success:
                 result = self.queue.send_success_reply(self.file_props,
                     self.streamhost)
-                if self.type == 'sender' and self.proxy:
-                    self.queue.process_result( self.send_file()
-                            , self)
+                if self.type_ == 'sender' and self.proxy:
+                    self.queue.process_result(self.send_file(), self)
                     return
 
                 if result == 0:
@@ -1264,7 +1249,6 @@ class Socks5Client(Socks5):
             self.state += 1
             return None
 
-
     def pollin(self):
         self.idlequeue.remove_timeout(self.fd)
         if self.connected:
@@ -1325,33 +1309,24 @@ class Socks5Client(Socks5):
             self.queue.reconnect_client(self, self.streamhost)
 
 
-
 class Socks5SenderClient(Socks5Client, Socks5Sender):
 
     def __init__(self, idlequeue, sock_hash, parent,_sock, host=None,
-            port=None, fingerprint = None, connected=True, file_props={}):
-
+    port=None, fingerprint = None, connected=True, file_props={}):
         Socks5Client.__init__(self, idlequeue, host, port, None, None,
-                file_props.sid)
-
+            file_props.sid)
         Socks5Sender.__init__(self,idlequeue, sock_hash, parent,_sock,
-                host, port, fingerprint , connected, file_props)
-
-
-
+            host, port, fingerprint , connected, file_props)
 
 
 class Socks5SenderServer(Socks5Server, Socks5Sender):
 
     def __init__(self, idlequeue, sock_hash, parent,_sock, host=None,
-            port=None, fingerprint = None, connected=True, file_props={}):
-
+    port=None, fingerprint = None, connected=True, file_props={}):
         Socks5Server.__init__(self, idlequeue, host, port, None, None,
-                file_props.sid)
-
+            file_props.sid)
         Socks5Sender.__init__(self,idlequeue, sock_hash, parent, _sock,
-                host, port, fingerprint , connected, file_props)
-
+            host, port, fingerprint , connected, file_props)
 
 
 class Socks5ReceiverClient(Socks5Client, Socks5Receiver):
@@ -1359,27 +1334,21 @@ class Socks5ReceiverClient(Socks5Client, Socks5Receiver):
     def __init__(self, idlequeue, streamhost, sid, file_props = None,
             fingerprint=None):
         Socks5Client.__init__(self, idlequeue, streamhost['host'],
-                int(streamhost['port']), streamhost['initiator'],
-                streamhost['target'], sid)
-
+            int(streamhost['port']), streamhost['initiator'],
+            streamhost['target'], sid)
         Socks5Receiver.__init__(self, idlequeue, streamhost, sid, file_props,
-                       fingerprint)
-
-
+            fingerprint)
 
 
 class Socks5ReceiverServer(Socks5Server, Socks5Receiver):
 
     def __init__(self, idlequeue, streamhost, sid, file_props = None,
     fingerprint=None):
-
         Socks5Server.__init__(self, idlequeue, streamhost['host'],
-                int(streamhost['port']), streamhost['initiator'],
-                streamhost['target'], sid)
-
+            int(streamhost['port']), streamhost['initiator'],
+            streamhost['target'], sid)
         Socks5Receiver.__init__(self, idlequeue, streamhost, sid, file_props,
-                       fingerprint)
-
+            fingerprint)
 
 
 class Socks5Listener(IdleObject):
@@ -1395,7 +1364,7 @@ class Socks5Listener(IdleObject):
         """
         self.port = port
         self.ais = socket.getaddrinfo(None, port, socket.AF_UNSPEC,
-                socket.SOCK_STREAM, socket.SOL_TCP, socket.AI_PASSIVE)
+            socket.SOCK_STREAM, socket.SOL_TCP, socket.AI_PASSIVE)
         self.ais.sort(reverse=True) # Try IPv6 first
         self.queue_idx = -1
         self.idlequeue = idlequeue
@@ -1483,5 +1452,3 @@ class Socks5Listener(IdleObject):
         _sock[0].setblocking(False)
         self.connections.append(_sock[0])
         return _sock
-
-
diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py
index 618dd744a8..9e3ae6acb2 100644
--- a/src/common/stanza_session.py
+++ b/src/common/stanza_session.py
@@ -57,7 +57,7 @@ class StanzaSession(object):
         '''
         self.conn = conn
         self.jid = jid
-        self.type = type_
+        self.type_ = type_
         self.resource = jid.getResource()
 
         if thread_id:
diff --git a/src/config.py b/src/config.py
index 0b7db54639..4dc64621e7 100644
--- a/src/config.py
+++ b/src/config.py
@@ -4103,7 +4103,7 @@ class ManagePEPServicesWindow:
 
     def _nec_pep_config_received(self, obj):
         def on_ok(form, node):
-            form.type = 'submit'
+            form.type_ = 'submit'
             our_jid = gajim.get_jid_from_account(self.account)
             gajim.connections[self.account].send_pb_configure(our_jid, node, form)
         window = dialogs.DataFormWindow(obj.form, (on_ok, obj.node))
diff --git a/src/dataforms_widget.py b/src/dataforms_widget.py
index 25f0b93b80..eab2272358 100644
--- a/src/dataforms_widget.py
+++ b/src/dataforms_widget.py
@@ -185,7 +185,7 @@ class DataFormWidget(gtk.Alignment, object):
             # note: we store also text-private and hidden fields,
             # we just do not display them.
             # TODO: boolean fields
-            #elif field.type=='boolean': fieldtypes.append(bool)
+            #elif field.type_=='boolean': fieldtypes.append(bool)
             fieldtypes.append(str)
             fieldvars.append(field.var)
 
@@ -215,7 +215,7 @@ class DataFormWidget(gtk.Alignment, object):
 
         self.clean_data_form = self.clean_multiple_data_form
 
-        readwrite = self._data_form.type != 'result'
+        readwrite = self._data_form.type_ != 'result'
         if not readwrite:
             self.buttons_vbox.set_no_show_all(True)
             self.buttons_vbox.hide()
@@ -343,25 +343,25 @@ class SingleForm(gtk.Table, object):
         linecounter = 0
 
         # is the form changeable?
-        readwrite = dataform.type != 'result'
+        readwrite = dataform.type_ != 'result'
 
         # for each field...
         for field in self._data_form.iter_fields():
-            if field.type == 'hidden': continue
+            if field.type_ == 'hidden': continue
 
             commonlabel = True
             commonlabelcenter = False
             commonwidget = True
             widget = None
 
-            if field.type == 'boolean':
+            if field.type_ == 'boolean':
                 commonlabelcenter = True
                 widget = gtk.CheckButton()
                 widget.connect('toggled', self.on_boolean_checkbutton_toggled,
                         field)
                 widget.set_active(field.value)
 
-            elif field.type == 'fixed':
+            elif field.type_ == 'fixed':
                 leftattach = 1
                 rightattach = 2
                 if field.label is None:
@@ -375,7 +375,7 @@ class SingleForm(gtk.Table, object):
                 self.attach(widget, leftattach, rightattach, linecounter,
                         linecounter+1, xoptions=gtk.FILL, yoptions=gtk.FILL)
 
-            elif field.type == 'list-single':
+            elif field.type_ == 'list-single':
                 # TODO: What if we have radio buttons and non-required field?
                 # TODO: We cannot deactivate them all...
                 if len(field.options) < 6:
@@ -409,7 +409,7 @@ class SingleForm(gtk.Table, object):
                     widget.connect('changed', on_list_single_combobox_changed, field)
                 widget.set_sensitive(readwrite)
 
-            elif field.type == 'list-multi':
+            elif field.type_ == 'list-multi':
                 # TODO: When more than few choices, make a list
                 if len(field.options) < 6:
                     # 5 option max: show checkbutton
@@ -439,12 +439,12 @@ class SingleForm(gtk.Table, object):
                             on_list_multi_treeview_changed, field)
                     tv.set_sensitive(readwrite)
 
-            elif field.type == 'jid-single':
+            elif field.type_ == 'jid-single':
                 widget = gtk.Entry()
                 widget.connect('changed', self.on_text_single_entry_changed, field)
                 widget.set_text(field.value)
 
-            elif field.type == 'jid-multi':
+            elif field.type_ == 'jid-multi':
                 commonwidget = False
 
                 xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
@@ -493,14 +493,14 @@ class SingleForm(gtk.Table, object):
 
                 del xml
 
-            elif field.type == 'text-private':
+            elif field.type_ == 'text-private':
                 commonlabelcenter = True
                 widget = gtk.Entry()
                 widget.connect('changed', self.on_text_single_entry_changed, field)
                 widget.set_visibility(False)
                 widget.set_text(field.value)
 
-            elif field.type == 'text-multi':
+            elif field.type_ == 'text-multi':
                 # TODO: bigger text view
                 commonwidget = False
 
@@ -524,7 +524,7 @@ class SingleForm(gtk.Table, object):
                 self.attach(widget, 1, 2, linecounter, linecounter+1)
 
             else:
-                # field.type == 'text-single' or field.type is nonstandard:
+                # field.type_ == 'text-single' or field.type_ is nonstandard:
                 # JEP says that if we don't understand some type, we
                 # should handle it as text-single
                 commonlabelcenter = True
diff --git a/src/groupchat_control.py b/src/groupchat_control.py
index a7dce1a9e6..d839d20257 100644
--- a/src/groupchat_control.py
+++ b/src/groupchat_control.py
@@ -950,7 +950,7 @@ class GroupchatControl(ChatControlBase):
                 if not self.form_widget:
                     return
                 form_node = self.form_widget.data_form.get_purged()
-                form_node.type = 'submit'
+                form_node.type_ = 'submit'
                 obj.conn.send_captcha(self.room_jid, form_node)
                 self.form_widget.hide()
                 self.form_widget.destroy()
diff --git a/src/search_window.py b/src/search_window.py
index 2a0b41ad9d..1b2f3a02b9 100644
--- a/src/search_window.py
+++ b/src/search_window.py
@@ -89,7 +89,7 @@ class SearchWindow:
 
     def on_search_button_clicked(self, button):
         if self.is_form:
-            self.data_form_widget.data_form.type = 'submit'
+            self.data_form_widget.data_form.type_ = 'submit'
             gajim.connections[self.account].send_search_form(self.jid,
                     self.data_form_widget.data_form.get_purged(), True)
         else:
diff --git a/src/statusicon.py b/src/statusicon.py
index f5bc54d77f..116d7a87a3 100644
--- a/src/statusicon.py
+++ b/src/statusicon.py
@@ -439,7 +439,7 @@ class StatusIcon:
 
     def on_clicked(self, widget, event):
         self.on_tray_leave_notify_event(widget, None)
-        if event.type != gtk.gdk.BUTTON_PRESS:
+        if event.type_ != gtk.gdk.BUTTON_PRESS:
             return
         if event.button == 1: # Left click
             self.on_left_click()
diff --git a/test/lib/gajim_mocks.py b/test/lib/gajim_mocks.py
index 52b8d07569..4070641e93 100644
--- a/test/lib/gajim_mocks.py
+++ b/test/lib/gajim_mocks.py
@@ -133,7 +133,7 @@ class MockSession(Mock):
 
         self.conn = conn
         self.jid = jid
-        self.type = type_
+        self.type_ = type_
         self.thread_id = thread_id
 
         if not self.thread_id:
-- 
GitLab