Philipp Hörist pushed to branch master at gajim / gajim

Commits:

24 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -14,7 +14,7 @@ run-tests:
    14 14
         - . ./civenv/bin/activate
    
    15 15
         - pip3 install mypy
    
    16 16
         - pip3 install git+https://dev.gajim.org/gajim/python-nbxmpp.git@master
    
    17
    -    - pip3 install pylint==2.1.1
    
    17
    +    - pip3 install pylint==2.3.1
    
    18 18
         - mypy gajim
    
    19 19
         - scripts/dev/pylint-ci.sh --jobs=2 gajim
    
    20 20
         - python3 setup.py test -s test.no_gui
    

  • gajim/chat_control_base.py
    ... ... @@ -131,7 +131,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    131 131
             """
    
    132 132
             Derived types SHOULD implement this
    
    133 133
             """
    
    134
    -        pass
    
    135 134
     
    
    136 135
         def update_ui(self):
    
    137 136
             """
    
    ... ... @@ -149,13 +148,11 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    149 148
             """
    
    150 149
             Derived types MAY implement this
    
    151 150
             """
    
    152
    -        pass
    
    153 151
     
    
    154 152
         def _update_toolbar(self):
    
    155 153
             """
    
    156 154
             Derived types MAY implement this
    
    157 155
             """
    
    158
    -        pass
    
    159 156
     
    
    160 157
         def _nec_our_status(self, obj):
    
    161 158
             if self.account != obj.conn.name:
    
    ... ... @@ -698,7 +695,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    698 695
             """
    
    699 696
             Derived types SHOULD implement this
    
    700 697
             """
    
    701
    -        pass
    
    702 698
     
    
    703 699
         def _on_drag_leave(self, *args):
    
    704 700
             # FIXME: DND on non editable TextView, find a better way
    
    ... ... @@ -840,7 +836,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    840 836
                 history = self.received_history
    
    841 837
                 pos = self.received_history_pos
    
    842 838
             size = len(history)
    
    843
    -        scroll = False if pos == size else True # are we scrolling?
    
    839
    +        scroll = pos != size
    
    844 840
             # we don't want size of the buffer to grow indefinitely
    
    845 841
             max_size = app.config.get('key_up_lines')
    
    846 842
             for _i in range(size - max_size + 1):
    

  • gajim/command_system/errors.py
    ... ... @@ -38,16 +38,13 @@ class DefinitionError(BaseError):
    38 38
         """
    
    39 39
         Used to indicate errors occurred on command definition.
    
    40 40
         """
    
    41
    -    pass
    
    42 41
     
    
    43 42
     class CommandError(BaseError):
    
    44 43
         """
    
    45 44
         Used to indicate errors occurred during command execution.
    
    46 45
         """
    
    47
    -    pass
    
    48 46
     
    
    49 47
     class NoCommandError(BaseError):
    
    50 48
         """
    
    51 49
         Used to indicate an inability to find the specified command.
    
    52 50
         """
    53
    -    pass

  • gajim/command_system/framework.py
    ... ... @@ -114,14 +114,12 @@ class CommandProcessor:
    114 114
             If returns True then command execution will be interrupted and
    
    115 115
             command will not be executed.
    
    116 116
             """
    
    117
    -        pass
    
    118 117
     
    
    119 118
         def command_postprocessor(self, cmd, name, arguments, args, kwargs, value):
    
    120 119
             """
    
    121 120
             Redefine this method in the subclass to execute custom code
    
    122 121
             after command gets executed.
    
    123 122
             """
    
    124
    -        pass
    
    125 123
     
    
    126 124
         def looks_like_command(self, text, body, name, arguments):
    
    127 125
             """
    
    ... ... @@ -132,7 +130,6 @@ class CommandProcessor:
    132 130
             be interrupted and that value will be used to return from
    
    133 131
             process_as_command.
    
    134 132
             """
    
    135
    -        pass
    
    136 133
     
    
    137 134
         def get_command(self, name):
    
    138 135
             cmd = get_command(self.COMMAND_HOST, name)
    

  • gajim/common/app.py
    ... ... @@ -234,14 +234,14 @@ def detect_dependencies():
    234 234
     
    
    235 235
         # ZEROCONF
    
    236 236
         try:
    
    237
    -        import pybonjour  # pylint: disable=unused-variable
    
    237
    +        import pybonjour  # pylint: disable=unused-import
    
    238 238
             _dependencies['PYBONJOUR'] = True
    
    239 239
         except Exception:
    
    240 240
             pass
    
    241 241
     
    
    242 242
         try:
    
    243 243
             gi.require_version('Avahi', '0.6')
    
    244
    -        from gi.repository import Avahi  # pylint: disable=unused-variable
    
    244
    +        from gi.repository import Avahi  # pylint: disable=unused-import
    
    245 245
             _dependencies['AVAHI'] = True
    
    246 246
         except Exception:
    
    247 247
             pass
    
    ... ... @@ -305,7 +305,7 @@ def detect_dependencies():
    305 305
         # GEOCLUE
    
    306 306
         try:
    
    307 307
             gi.require_version('Geoclue', '2.0')
    
    308
    -        from gi.repository import Geoclue  # pylint: disable=unused-variable
    
    308
    +        from gi.repository import Geoclue  # pylint: disable=unused-import
    
    309 309
             _dependencies['GEOCLUE'] = True
    
    310 310
         except (ImportError, ValueError):
    
    311 311
             pass
    
    ... ... @@ -322,7 +322,7 @@ def detect_dependencies():
    322 322
     
    
    323 323
         # PYCURL
    
    324 324
         try:
    
    325
    -        import pycurl  # pylint: disable=unused-variable
    
    325
    +        import pycurl  # pylint: disable=unused-import
    
    326 326
             _dependencies['PYCURL'] = True
    
    327 327
         except ImportError:
    
    328 328
             pass
    

  • gajim/common/events.py
    ... ... @@ -261,8 +261,7 @@ class Events:
    261 261
                         self._events[account][jid].remove(event)
    
    262 262
                     self.fire_event_removed([event])
    
    263 263
                     return
    
    264
    -            else:
    
    265
    -                return True
    
    264
    +            return True
    
    266 265
             if types:
    
    267 266
                 new_list = [] # list of events to keep
    
    268 267
                 removed_list = [] # list of removed events
    

  • gajim/common/exceptions.py
    ... ... @@ -97,13 +97,11 @@ class NegotiationError(Exception):
    97 97
         """
    
    98 98
         A session negotiation failed
    
    99 99
         """
    
    100
    -    pass
    
    101 100
     
    
    102 101
     class Cancelled(Exception):
    
    103 102
         """
    
    104 103
         The user cancelled an operation
    
    105 104
         """
    
    106
    -    pass
    
    107 105
     
    
    108 106
     class LatexError(Exception):
    
    109 107
         """
    

  • gajim/common/fuzzyclock.py
    ... ... @@ -90,8 +90,6 @@ class FuzzyClock:
    90 90
                     '0': self.HOUR_NAMES[now.tm_hour % 12],
    
    91 91
                     '1': self.HOUR_NAMES[(now.tm_hour + 1) % 12]}
    
    92 92
     
    
    93
    -        elif fuzzyness == 3:
    
    93
    +        if fuzzyness == 3:
    
    94 94
                 return self.FUZZY_DAYTIME[int(round(now.tm_hour / 3.0))]
    
    95
    -
    
    96
    -        else:
    
    97
    -            return self.FUZZY_WEEK[now.tm_wday]
    95
    +        return self.FUZZY_WEEK[now.tm_wday]

  • gajim/common/jingle_ft.py
    ... ... @@ -307,8 +307,7 @@ class JingleFileTransfer(JingleContent):
    307 307
                 self.__state_changed(State.CAND_SENT_AND_RECEIVED, args)
    
    308 308
                 self.__state_changed(State.TRANSFERING)
    
    309 309
                 raise nbxmpp.NodeProcessed
    
    310
    -        else:
    
    311
    -            self.__state_changed(State.CAND_RECEIVED, args)
    
    310
    +        self.__state_changed(State.CAND_RECEIVED, args)
    
    312 311
     
    
    313 312
         def __on_iq_result(self, stanza, content, error, action):
    
    314 313
             log.info("__on_iq_result")
    

  • gajim/common/jingle_session.py
    ... ... @@ -593,9 +593,9 @@ class JingleSession:
    593 593
                     text = 'Content %s (created by %s) does not exist' % (name, creator)
    
    594 594
                     self.__send_error(stanza, 'bad-request', text=text, type_='_modify')
    
    595 595
                     raise nbxmpp.NodeProcessed
    
    596
    -            else:
    
    597
    -                cn = self.contents[(creator, name)]
    
    598
    -                cn.on_stanza(stanza, content, error, action)
    
    596
    +
    
    597
    +            cn = self.contents[(creator, name)]
    
    598
    +            cn.on_stanza(stanza, content, error, action)
    
    599 599
     
    
    600 600
         def __on_session_terminate(self, stanza, jingle, error, action):
    
    601 601
             self.connection.delete_jingle_session(self.sid)
    

  • gajim/common/jingle_transport.py
    ... ... @@ -74,7 +74,6 @@ class JingleTransport:
    74 74
             """
    
    75 75
             Build a candidate stanza for the given candidate
    
    76 76
             """
    
    77
    -        pass
    
    78 77
     
    
    79 78
         def make_transport(self, candidates=None):
    
    80 79
             """
    

  • gajim/common/modules/adhoc_commands.py
    ... ... @@ -438,44 +438,44 @@ class AdHocCommands(BaseModule):
    438 438
                     self._sessions[(jid, sessionid, node)] = obj
    
    439 439
                 self._log.info('Comand %s executed: %s', node, jid)
    
    440 440
                 raise nbxmpp.NodeProcessed
    
    441
    -        else:
    
    442
    -            # the command is already running, check for it
    
    443
    -            magictuple = (jid, sessionid, node)
    
    444
    -            if magictuple not in self._sessions:
    
    445
    -                # we don't have this session... ha!
    
    446
    -                self._log.warning('Invalid session %s', magictuple)
    
    447
    -                raise nbxmpp.NodeProcessed
    
    448 441
     
    
    449
    -            action = cmd.getAttr('action')
    
    450
    -            obj = self._sessions[magictuple]
    
    451
    -
    
    452
    -            try:
    
    453
    -                if action == 'cancel':
    
    454
    -                    rc = obj.cancel(stanza)
    
    455
    -                elif action == 'prev':
    
    456
    -                    rc = obj.prev(stanza)
    
    457
    -                elif action == 'next':
    
    458
    -                    rc = obj.next(stanza)
    
    459
    -                elif action == 'execute' or action is None:
    
    460
    -                    rc = obj.execute(stanza)
    
    461
    -                elif action == 'complete':
    
    462
    -                    rc = obj.complete(stanza)
    
    463
    -                else:
    
    464
    -                    # action is wrong. stop the session, send error
    
    465
    -                    raise AttributeError
    
    466
    -            except AttributeError:
    
    467
    -                # the command probably doesn't handle invoked action...
    
    468
    -                # stop the session, return error
    
    469
    -                del self._sessions[magictuple]
    
    470
    -                self._log.warning('Wrong action %s %s', node, jid)
    
    471
    -                raise nbxmpp.NodeProcessed
    
    442
    +        # the command is already running, check for it
    
    443
    +        magictuple = (jid, sessionid, node)
    
    444
    +        if magictuple not in self._sessions:
    
    445
    +            # we don't have this session... ha!
    
    446
    +            self._log.warning('Invalid session %s', magictuple)
    
    447
    +            raise nbxmpp.NodeProcessed
    
    472 448
     
    
    473
    -            # delete the session if rc is False
    
    474
    -            if not rc:
    
    475
    -                del self._sessions[magictuple]
    
    449
    +        action = cmd.getAttr('action')
    
    450
    +        obj = self._sessions[magictuple]
    
    476 451
     
    
    452
    +        try:
    
    453
    +            if action == 'cancel':
    
    454
    +                rc = obj.cancel(stanza)
    
    455
    +            elif action == 'prev':
    
    456
    +                rc = obj.prev(stanza)
    
    457
    +            elif action == 'next':
    
    458
    +                rc = obj.next(stanza)
    
    459
    +            elif action == 'execute' or action is None:
    
    460
    +                rc = obj.execute(stanza)
    
    461
    +            elif action == 'complete':
    
    462
    +                rc = obj.complete(stanza)
    
    463
    +            else:
    
    464
    +                # action is wrong. stop the session, send error
    
    465
    +                raise AttributeError
    
    466
    +        except AttributeError:
    
    467
    +            # the command probably doesn't handle invoked action...
    
    468
    +            # stop the session, return error
    
    469
    +            del self._sessions[magictuple]
    
    470
    +            self._log.warning('Wrong action %s %s', node, jid)
    
    477 471
                 raise nbxmpp.NodeProcessed
    
    478 472
     
    
    473
    +        # delete the session if rc is False
    
    474
    +        if not rc:
    
    475
    +            del self._sessions[magictuple]
    
    476
    +
    
    477
    +        raise nbxmpp.NodeProcessed
    
    478
    +
    
    479 479
         def send_command(self, jid, node, session_id,
    
    480 480
                          form, action='execute'):
    
    481 481
             """
    

  • gajim/common/protocol/bytestream.py
    ... ... @@ -757,11 +757,10 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
    757 757
                 app.socks5queue.on_success[file_props.sid] = self._proxy_auth_ok
    
    758 758
                 raise nbxmpp.NodeProcessed
    
    759 759
     
    
    760
    +        if file_props.stopped:
    
    761
    +            self.remove_transfer(file_props)
    
    760 762
             else:
    
    761
    -            if file_props.stopped:
    
    762
    -                self.remove_transfer(file_props)
    
    763
    -            else:
    
    764
    -                app.socks5queue.send_file(file_props, self.name, 'server')
    
    763
    +            app.socks5queue.send_file(file_props, self.name, 'server')
    
    765 764
     
    
    766 765
             raise nbxmpp.NodeProcessed
    
    767 766
     
    

  • gajim/common/socks5.py
    ... ... @@ -712,10 +712,10 @@ class Socks5:
    712 712
                     return None
    
    713 713
                 self.file_props.stalled = False
    
    714 714
                 return lenn
    
    715
    -        else:
    
    716
    -            self.state = 8 # end connection
    
    717
    -            self.disconnect()
    
    718
    -            return -1
    
    715
    +
    
    716
    +        self.state = 8 # end connection
    
    717
    +        self.disconnect()
    
    718
    +        return -1
    
    719 719
     
    
    720 720
         def _on_send_exception(self):
    
    721 721
             # peer stopped reading
    

  • gajim/common/zeroconf/zeroconf.py
    ... ... @@ -40,14 +40,14 @@ def test_avahi():
    40 40
         try:
    
    41 41
             import gi
    
    42 42
             gi.require_version('Avahi', '0.6')
    
    43
    -        from gi.repository import Avahi  # pylint: disable=unused-variable
    
    43
    +        from gi.repository import Avahi  # pylint: disable=unused-import
    
    44 44
         except (ImportError, ValueError):
    
    45 45
             return False
    
    46 46
         return True
    
    47 47
     
    
    48 48
     def test_bonjour():
    
    49 49
         try:
    
    50
    -        import pybonjour  # pylint: disable=unused-variable
    
    50
    +        import pybonjour  # pylint: disable=unused-import
    
    51 51
         except ImportError:
    
    52 52
             return False
    
    53 53
         except WindowsError: # pylint: disable=undefined-variable
    

  • gajim/dev/ipython_view.py
    ... ... @@ -585,7 +585,6 @@ class ConsoleView(Gtk.TextView):
    585 585
             """
    
    586 586
             For some reason we can't extend onKeyPress directly (bug #500900)
    
    587 587
             """
    
    588
    -        pass
    
    589 588
     
    
    590 589
     class IPythonView(ConsoleView, IterableIPShell):
    
    591 590
         '''
    

  • gajim/dialogs.py
    ... ... @@ -574,7 +574,6 @@ class TimeoutDialog:
    574 574
             """
    
    575 575
             To be implemented in derivated classes
    
    576 576
             """
    
    577
    -        pass
    
    578 577
     
    
    579 578
         def countdown(self):
    
    580 579
             if self.countdown_enabled:
    

  • gajim/gtk/account_wizard.py
    ... ... @@ -200,7 +200,7 @@ class AccountCreationWizard:
    200 200
                 self.back_button.set_sensitive(True)
    
    201 201
                 return
    
    202 202
     
    
    203
    -        elif cur_page == 1:
    
    203
    +        if cur_page == 1:
    
    204 204
                 # We are adding an existing account
    
    205 205
                 anonymous = self.xml.get_object('anonymous_checkbutton1').\
    
    206 206
                     get_active()
    

  • gajim/gtk/dialogs.py
    ... ... @@ -649,7 +649,6 @@ class InputDialog(CommonInputDialog):
    649 649
             '''
    
    650 650
             may be implemented by subclasses
    
    651 651
             '''
    
    652
    -        pass
    
    653 652
     
    
    654 653
         def set_entry(self, value):
    
    655 654
             self.input_entry.set_text(value)
    

  • gajim/gtk/discovery.py
    ... ... @@ -908,7 +908,6 @@ class AgentBrowser:
    908 908
             """
    
    909 909
             Called when the default theme is changed
    
    910 910
             """
    
    911
    -        pass
    
    912 911
     
    
    913 912
         def on_browse_button_clicked(self, widget=None):
    
    914 913
             """
    
    ... ... @@ -1095,7 +1094,6 @@ class AgentBrowser:
    1095 1094
     
    
    1096 1095
         def _update_error(self, iter_, jid, node):
    
    1097 1096
             '''Called when a disco#info query failed for an item.'''
    
    1098
    -        pass
    
    1099 1097
     
    
    1100 1098
     
    
    1101 1099
     class ToplevelAgentBrowser(AgentBrowser):
    

  • gajim/gtk/features.py
    ... ... @@ -158,7 +158,7 @@ class FeaturesDialog(Gtk.Dialog):
    158 158
                 return True
    
    159 159
             try:
    
    160 160
                 gi.require_version('Secret', '1')
    
    161
    -            from gi.repository import Secret  # pylint: disable=unused-variable
    
    161
    +            from gi.repository import Secret  # pylint: disable=unused-import
    
    162 162
             except (ValueError, ImportError):
    
    163 163
                 return False
    
    164 164
             return True
    

  • gajim/gui_menu_builder.py
    ... ... @@ -42,10 +42,10 @@ def build_resources_submenu(contacts, account, action, room_jid=None,
    42 42
             item = Gtk.MenuItem.new_with_label(
    
    43 43
                 '%s (%s)' % (c.resource, str(c.priority)))
    
    44 44
             sub_menu.append(item)
    
    45
    -        if action == roster.on_invite_to_room:
    
    45
    +        if action == roster.on_invite_to_room:  # pylint: disable=comparison-with-callable
    
    46 46
                 item.connect('activate', action, [(c, account)], room_jid,
    
    47 47
                         room_account, c.resource)
    
    48
    -        elif action == roster.on_invite_to_new_room:
    
    48
    +        elif action == roster.on_invite_to_new_room:  # pylint: disable=comparison-with-callable
    
    49 49
                 item.connect('activate', action, [(c, account)], c.resource)
    
    50 50
             else: # start_chat, execute_command, send_file
    
    51 51
                 item.connect('activate', action, c, account, c.resource)
    

  • gajim/message_control.py
    ... ... @@ -78,8 +78,9 @@ class MessageControl:
    78 78
             """
    
    79 79
             Called when the control becomes active (state is True) or inactive (state
    
    80 80
             is False)
    
    81
    +
    
    82
    +        Derived classes MUST implement this method
    
    81 83
             """
    
    82
    -        pass  # Derived classes MUST implement this method
    
    83 84
     
    
    84 85
         def minimizable(self):
    
    85 86
             """
    
    ... ... @@ -121,31 +122,26 @@ class MessageControl:
    121 122
             """
    
    122 123
             Derived classes SHOULD implement this
    
    123 124
             """
    
    124
    -        pass
    
    125 125
     
    
    126 126
         def update_ui(self):
    
    127 127
             """
    
    128 128
             Derived classes SHOULD implement this
    
    129 129
             """
    
    130
    -        pass
    
    131 130
     
    
    132 131
         def toggle_emoticons(self):
    
    133 132
             """
    
    134 133
             Derived classes MAY implement this
    
    135 134
             """
    
    136
    -        pass
    
    137 135
     
    
    138 136
         def update_font(self):
    
    139 137
             """
    
    140 138
             Derived classes SHOULD implement this
    
    141 139
             """
    
    142
    -        pass
    
    143 140
     
    
    144 141
         def update_tags(self):
    
    145 142
             """
    
    146 143
             Derived classes SHOULD implement this
    
    147 144
             """
    
    148
    -        pass
    
    149 145
     
    
    150 146
         def get_tab_label(self, chatstate):
    
    151 147
             """
    
    ... ... @@ -157,7 +153,6 @@ class MessageControl:
    157 153
             """
    
    158 154
             # Return a markup'd label and optional Gtk.Color in a tuple like:
    
    159 155
             # return (label_str, None)
    
    160
    -        pass
    
    161 156
     
    
    162 157
         def get_tab_image(self, count_unread=True):
    
    163 158
             # Return a suitable tab image for display.
    

  • gajim/plugins/helpers.py
    ... ... @@ -42,7 +42,6 @@ class GajimPluginActivateException(Exception):
    42 42
         '''
    
    43 43
         Raised when activation failed
    
    44 44
         '''
    
    45
    -    pass
    
    46 45
     
    
    47 46
     class log_calls:
    
    48 47
         '''