Philipp Hörist pushed to branch master at gajim / gajim
Commits: 3b221177 by Philipp Hörist at 2019-04-07T16:14:54Z Fix unused-import pylint errors
- - - - - 47dae61e by Philipp Hörist at 2019-04-07T16:20:15Z Fix unnecessary-pass pylint errors
- - - - - b09f94da by Philipp Hörist at 2019-04-07T16:22:45Z Fix simplifiable-if-expression pylint errors
- - - - - 30f850b5 by Philipp Hörist at 2019-04-07T16:26:29Z Fix no-else-return pylint errors
- - - - - c8815a92 by Philipp Hörist at 2019-04-07T16:40:32Z Fix no-else-raise pylint errors
- - - - - 0dbb3eb1 by Philipp Hörist at 2019-04-07T16:48:51Z Fix comparison-with-callable pylint errors
- - - - - 5471980a by Philipp Hörist at 2019-04-07T16:49:27Z Update pylint to 2.3.1
- - - - -
24 changed files:
- .gitlab-ci.yml - gajim/chat_control_base.py - gajim/command_system/errors.py - gajim/command_system/framework.py - gajim/common/app.py - gajim/common/events.py - gajim/common/exceptions.py - gajim/common/fuzzyclock.py - gajim/common/jingle_ft.py - gajim/common/jingle_session.py - gajim/common/jingle_transport.py - gajim/common/modules/adhoc_commands.py - gajim/common/protocol/bytestream.py - gajim/common/socks5.py - gajim/common/zeroconf/zeroconf.py - gajim/dev/ipython_view.py - gajim/dialogs.py - gajim/gtk/account_wizard.py - gajim/gtk/dialogs.py - gajim/gtk/discovery.py - gajim/gtk/features.py - gajim/gui_menu_builder.py - gajim/message_control.py - gajim/plugins/helpers.py
Changes:
===================================== .gitlab-ci.yml ===================================== @@ -14,7 +14,7 @@ run-tests: - . ./civenv/bin/activate - pip3 install mypy - pip3 install git+https://dev.gajim.org/gajim/python-nbxmpp.git@master - - pip3 install pylint==2.1.1 + - pip3 install pylint==2.3.1 - mypy gajim - scripts/dev/pylint-ci.sh --jobs=2 gajim - python3 setup.py test -s test.no_gui
===================================== gajim/chat_control_base.py ===================================== @@ -131,7 +131,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ Derived types SHOULD implement this """ - pass
def update_ui(self): """ @@ -149,13 +148,11 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ Derived types MAY implement this """ - pass
def _update_toolbar(self): """ Derived types MAY implement this """ - pass
def _nec_our_status(self, obj): if self.account != obj.conn.name: @@ -698,7 +695,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ Derived types SHOULD implement this """ - pass
def _on_drag_leave(self, *args): # FIXME: DND on non editable TextView, find a better way @@ -840,7 +836,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): history = self.received_history pos = self.received_history_pos size = len(history) - scroll = False if pos == size else True # are we scrolling? + scroll = pos != size # we don't want size of the buffer to grow indefinitely max_size = app.config.get('key_up_lines') for _i in range(size - max_size + 1):
===================================== gajim/command_system/errors.py ===================================== @@ -38,16 +38,13 @@ class DefinitionError(BaseError): """ Used to indicate errors occurred on command definition. """ - pass
class CommandError(BaseError): """ Used to indicate errors occurred during command execution. """ - pass
class NoCommandError(BaseError): """ Used to indicate an inability to find the specified command. """ - pass
===================================== gajim/command_system/framework.py ===================================== @@ -114,14 +114,12 @@ class CommandProcessor: If returns True then command execution will be interrupted and command will not be executed. """ - pass
def command_postprocessor(self, cmd, name, arguments, args, kwargs, value): """ Redefine this method in the subclass to execute custom code after command gets executed. """ - pass
def looks_like_command(self, text, body, name, arguments): """ @@ -132,7 +130,6 @@ class CommandProcessor: be interrupted and that value will be used to return from process_as_command. """ - pass
def get_command(self, name): cmd = get_command(self.COMMAND_HOST, name)
===================================== gajim/common/app.py ===================================== @@ -234,14 +234,14 @@ def detect_dependencies():
# ZEROCONF try: - import pybonjour # pylint: disable=unused-variable + import pybonjour # pylint: disable=unused-import _dependencies['PYBONJOUR'] = True except Exception: pass
try: gi.require_version('Avahi', '0.6') - from gi.repository import Avahi # pylint: disable=unused-variable + from gi.repository import Avahi # pylint: disable=unused-import _dependencies['AVAHI'] = True except Exception: pass @@ -305,7 +305,7 @@ def detect_dependencies(): # GEOCLUE try: gi.require_version('Geoclue', '2.0') - from gi.repository import Geoclue # pylint: disable=unused-variable + from gi.repository import Geoclue # pylint: disable=unused-import _dependencies['GEOCLUE'] = True except (ImportError, ValueError): pass @@ -322,7 +322,7 @@ def detect_dependencies():
# PYCURL try: - import pycurl # pylint: disable=unused-variable + import pycurl # pylint: disable=unused-import _dependencies['PYCURL'] = True except ImportError: pass
===================================== gajim/common/events.py ===================================== @@ -261,8 +261,7 @@ class Events: self._events[account][jid].remove(event) self.fire_event_removed([event]) return - else: - return True + return True if types: new_list = [] # list of events to keep removed_list = [] # list of removed events
===================================== gajim/common/exceptions.py ===================================== @@ -97,13 +97,11 @@ class NegotiationError(Exception): """ A session negotiation failed """ - pass
class Cancelled(Exception): """ The user cancelled an operation """ - pass
class LatexError(Exception): """
===================================== gajim/common/fuzzyclock.py ===================================== @@ -90,8 +90,6 @@ class FuzzyClock: '0': self.HOUR_NAMES[now.tm_hour % 12], '1': self.HOUR_NAMES[(now.tm_hour + 1) % 12]}
- elif fuzzyness == 3: + if fuzzyness == 3: return self.FUZZY_DAYTIME[int(round(now.tm_hour / 3.0))] - - else: - return self.FUZZY_WEEK[now.tm_wday] + return self.FUZZY_WEEK[now.tm_wday]
===================================== gajim/common/jingle_ft.py ===================================== @@ -307,8 +307,7 @@ class JingleFileTransfer(JingleContent): self.__state_changed(State.CAND_SENT_AND_RECEIVED, args) self.__state_changed(State.TRANSFERING) raise nbxmpp.NodeProcessed - else: - self.__state_changed(State.CAND_RECEIVED, args) + self.__state_changed(State.CAND_RECEIVED, args)
def __on_iq_result(self, stanza, content, error, action): log.info("__on_iq_result")
===================================== gajim/common/jingle_session.py ===================================== @@ -593,9 +593,9 @@ class JingleSession: text = 'Content %s (created by %s) does not exist' % (name, creator) self.__send_error(stanza, 'bad-request', text=text, type_='_modify') raise nbxmpp.NodeProcessed - else: - cn = self.contents[(creator, name)] - cn.on_stanza(stanza, content, error, action) + + cn = self.contents[(creator, name)] + cn.on_stanza(stanza, content, error, action)
def __on_session_terminate(self, stanza, jingle, error, action): self.connection.delete_jingle_session(self.sid)
===================================== gajim/common/jingle_transport.py ===================================== @@ -74,7 +74,6 @@ class JingleTransport: """ Build a candidate stanza for the given candidate """ - pass
def make_transport(self, candidates=None): """
===================================== gajim/common/modules/adhoc_commands.py ===================================== @@ -438,44 +438,44 @@ class AdHocCommands(BaseModule): self._sessions[(jid, sessionid, node)] = obj self._log.info('Comand %s executed: %s', node, jid) raise nbxmpp.NodeProcessed - else: - # the command is already running, check for it - magictuple = (jid, sessionid, node) - if magictuple not in self._sessions: - # we don't have this session... ha! - self._log.warning('Invalid session %s', magictuple) - raise nbxmpp.NodeProcessed
- action = cmd.getAttr('action') - obj = self._sessions[magictuple] - - try: - if action == 'cancel': - rc = obj.cancel(stanza) - elif action == 'prev': - rc = obj.prev(stanza) - elif action == 'next': - rc = obj.next(stanza) - elif action == 'execute' or action is None: - rc = obj.execute(stanza) - elif action == 'complete': - rc = obj.complete(stanza) - else: - # action is wrong. stop the session, send error - raise AttributeError - except AttributeError: - # the command probably doesn't handle invoked action... - # stop the session, return error - del self._sessions[magictuple] - self._log.warning('Wrong action %s %s', node, jid) - raise nbxmpp.NodeProcessed + # the command is already running, check for it + magictuple = (jid, sessionid, node) + if magictuple not in self._sessions: + # we don't have this session... ha! + self._log.warning('Invalid session %s', magictuple) + raise nbxmpp.NodeProcessed
- # delete the session if rc is False - if not rc: - del self._sessions[magictuple] + action = cmd.getAttr('action') + obj = self._sessions[magictuple]
+ try: + if action == 'cancel': + rc = obj.cancel(stanza) + elif action == 'prev': + rc = obj.prev(stanza) + elif action == 'next': + rc = obj.next(stanza) + elif action == 'execute' or action is None: + rc = obj.execute(stanza) + elif action == 'complete': + rc = obj.complete(stanza) + else: + # action is wrong. stop the session, send error + raise AttributeError + except AttributeError: + # the command probably doesn't handle invoked action... + # stop the session, return error + del self._sessions[magictuple] + self._log.warning('Wrong action %s %s', node, jid) raise nbxmpp.NodeProcessed
+ # delete the session if rc is False + if not rc: + del self._sessions[magictuple] + + raise nbxmpp.NodeProcessed + def send_command(self, jid, node, session_id, form, action='execute'): """
===================================== gajim/common/protocol/bytestream.py ===================================== @@ -757,11 +757,10 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): app.socks5queue.on_success[file_props.sid] = self._proxy_auth_ok raise nbxmpp.NodeProcessed
+ if file_props.stopped: + self.remove_transfer(file_props) else: - if file_props.stopped: - self.remove_transfer(file_props) - else: - app.socks5queue.send_file(file_props, self.name, 'server') + app.socks5queue.send_file(file_props, self.name, 'server')
raise nbxmpp.NodeProcessed
===================================== gajim/common/socks5.py ===================================== @@ -712,10 +712,10 @@ class Socks5: return None self.file_props.stalled = False return lenn - else: - self.state = 8 # end connection - self.disconnect() - return -1 + + self.state = 8 # end connection + self.disconnect() + return -1
def _on_send_exception(self): # peer stopped reading
===================================== gajim/common/zeroconf/zeroconf.py ===================================== @@ -40,14 +40,14 @@ def test_avahi(): try: import gi gi.require_version('Avahi', '0.6') - from gi.repository import Avahi # pylint: disable=unused-variable + from gi.repository import Avahi # pylint: disable=unused-import except (ImportError, ValueError): return False return True
def test_bonjour(): try: - import pybonjour # pylint: disable=unused-variable + import pybonjour # pylint: disable=unused-import except ImportError: return False except WindowsError: # pylint: disable=undefined-variable
===================================== gajim/dev/ipython_view.py ===================================== @@ -585,7 +585,6 @@ class ConsoleView(Gtk.TextView): """ For some reason we can't extend onKeyPress directly (bug #500900) """ - pass
class IPythonView(ConsoleView, IterableIPShell): '''
===================================== gajim/dialogs.py ===================================== @@ -574,7 +574,6 @@ class TimeoutDialog: """ To be implemented in derivated classes """ - pass
def countdown(self): if self.countdown_enabled:
===================================== gajim/gtk/account_wizard.py ===================================== @@ -200,7 +200,7 @@ class AccountCreationWizard: self.back_button.set_sensitive(True) return
- elif cur_page == 1: + if cur_page == 1: # We are adding an existing account anonymous = self.xml.get_object('anonymous_checkbutton1').\ get_active()
===================================== gajim/gtk/dialogs.py ===================================== @@ -649,7 +649,6 @@ class InputDialog(CommonInputDialog): ''' may be implemented by subclasses ''' - pass
def set_entry(self, value): self.input_entry.set_text(value)
===================================== gajim/gtk/discovery.py ===================================== @@ -908,7 +908,6 @@ class AgentBrowser: """ Called when the default theme is changed """ - pass
def on_browse_button_clicked(self, widget=None): """ @@ -1095,7 +1094,6 @@ class AgentBrowser:
def _update_error(self, iter_, jid, node): '''Called when a disco#info query failed for an item.''' - pass
class ToplevelAgentBrowser(AgentBrowser):
===================================== gajim/gtk/features.py ===================================== @@ -158,7 +158,7 @@ class FeaturesDialog(Gtk.Dialog): return True try: gi.require_version('Secret', '1') - from gi.repository import Secret # pylint: disable=unused-variable + from gi.repository import Secret # pylint: disable=unused-import except (ValueError, ImportError): return False return True
===================================== gajim/gui_menu_builder.py ===================================== @@ -42,10 +42,10 @@ def build_resources_submenu(contacts, account, action, room_jid=None, item = Gtk.MenuItem.new_with_label( '%s (%s)' % (c.resource, str(c.priority))) sub_menu.append(item) - if action == roster.on_invite_to_room: + if action == roster.on_invite_to_room: # pylint: disable=comparison-with-callable item.connect('activate', action, [(c, account)], room_jid, room_account, c.resource) - elif action == roster.on_invite_to_new_room: + elif action == roster.on_invite_to_new_room: # pylint: disable=comparison-with-callable item.connect('activate', action, [(c, account)], c.resource) else: # start_chat, execute_command, send_file item.connect('activate', action, c, account, c.resource)
===================================== gajim/message_control.py ===================================== @@ -78,8 +78,9 @@ class MessageControl: """ Called when the control becomes active (state is True) or inactive (state is False) + + Derived classes MUST implement this method """ - pass # Derived classes MUST implement this method
def minimizable(self): """ @@ -121,31 +122,26 @@ class MessageControl: """ Derived classes SHOULD implement this """ - pass
def update_ui(self): """ Derived classes SHOULD implement this """ - pass
def toggle_emoticons(self): """ Derived classes MAY implement this """ - pass
def update_font(self): """ Derived classes SHOULD implement this """ - pass
def update_tags(self): """ Derived classes SHOULD implement this """ - pass
def get_tab_label(self, chatstate): """ @@ -157,7 +153,6 @@ class MessageControl: """ # Return a markup'd label and optional Gtk.Color in a tuple like: # return (label_str, None) - pass
def get_tab_image(self, count_unread=True): # Return a suitable tab image for display.
===================================== gajim/plugins/helpers.py ===================================== @@ -42,7 +42,6 @@ class GajimPluginActivateException(Exception): ''' Raised when activation failed ''' - pass
class log_calls: '''
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/45ac229fb13af7bf3cb9e20a0975ed7348...