Philipp Hörist pushed to branch master at gajim / gajim
Commits: 158d013a by Philipp Hörist at 2018-09-17T21:03:45Z Fix literal-comparison pylint errors
- - - - - 01694c6a by Philipp Hörist at 2018-09-17T21:25:55Z Fix simplifiable-if-statement pylint errors
- - - - - 67bb5a57 by Philipp Hörist at 2018-09-17T21:26:52Z Update pylint error list
- Check for R0123 literal-comparison - Check for R1703 simplifiable-if-statement
- - - - -
11 changed files:
- .gitlab-ci.yml - gajim/common/app.py - gajim/common/connection.py - gajim/common/dbus_support.py - gajim/common/zeroconf/client_zeroconf.py - gajim/conversation_textview.py - gajim/gtkgui_helpers.py - gajim/plugins/pluginmanager.py - gajim/remote_control.py - gajim/tooltips.py - scripts/dev/pre-push-tests.sh
Changes:
===================================== .gitlab-ci.yml ===================================== --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ run-mypy: run-pylint: stage: test script: - - pylint3 --jobs=2 --additional-builtins=_ --disable=all --enable=C0201,C0325,C1801,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0106,E0107,E0108,E0202,E0221,E0222,E0235,E0501,E0502,E0503,E0602,E0603,E0604,E0701,E0702,E1001,E1002,E1003,E1004,E1111,E1120,E1121,E1122,E1123,E1124,E1125,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701,R0205,W0102,W0611,W0612,W0621,W0702,W1201,W1202 gajim + - pylint3 --jobs=2 --additional-builtins=_ --disable=all --enable=C0201,C0325,C1801,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0106,E0107,E0108,E0202,E0221,E0222,E0235,E0501,E0502,E0503,E0602,E0603,E0604,E0701,E0702,E1001,E1002,E1003,E1004,E1111,E1120,E1121,E1122,E1123,E1124,E1125,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701,R0123,R0205,R1703,W0102,W0611,W0612,W0621,W0702,W1201,W1202 gajim
run-build: stage: build
===================================== gajim/common/app.py ===================================== --- a/gajim/common/app.py +++ b/gajim/common/app.py @@ -424,10 +424,8 @@ def account_supports_private_storage(account): def account_is_connected(account): if account not in connections: return False - if connections[account].connected > 1: # 0 is offline, 1 is connecting - return True - else: - return False + # 0 is offline, 1 is connecting + return connections[account].connected > 1
def is_invisible(account): return SHOW_LIST[connections[account].connected] == 'invisible' @@ -455,11 +453,9 @@ def get_number_of_securely_connected_accounts(): return num_of_secured
def account_is_securely_connected(account): - if account_is_connected(account) and \ - account in con_types and con_types[account] in ('tls', 'ssl'): - return True - else: + if not account_is_connected(account): return False + return con_types.get(account) in ('tls', 'ssl')
def get_transport_name_from_jid(jid, use_config_setting = True): """
===================================== gajim/common/connection.py ===================================== --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -732,7 +732,7 @@ class Connection(CommonConnection, ConnectionHandlers): return is_form = data[2] conf = data[1] - if data[4] is not '': + if data[4] != '': helpers.replace_dataform_media(conf, data[4]) if self.new_account_form: def _on_register_result(result):
===================================== gajim/common/dbus_support.py ===================================== --- a/gajim/common/dbus_support.py +++ b/gajim/common/dbus_support.py @@ -145,16 +145,14 @@ def get_interface(interface, path, start_service=True): started = True if interface not in running_services: # try to start the service - if start_service and dbus_iface.StartServiceByName(interface, dbus.UInt32(0)) == 1: - started = True - else: - started = False + started = start_service and dbus_iface.StartServiceByName( + interface, dbus.UInt32(0)) == 1 if not started: return None obj = bus.get_object(interface, path) return dbus.Interface(obj, interface) - except Exception as e: - log.debug(str(e)) + except Exception as error: + log.debug(error) return None
===================================== gajim/common/zeroconf/client_zeroconf.py ===================================== --- a/gajim/common/zeroconf/client_zeroconf.py +++ b/gajim/common/zeroconf/client_zeroconf.py @@ -598,10 +598,7 @@ class P2PConnection(IdleObject, PlugIn):
def _plug_idle(self): readable = self.state != 0 - if self.sendqueue or self.sendbuff: - writable = True - else: - writable = False + writable = self.sendqueue or self.sendbuff if self.writable != writable or self.readable != readable: app.idlequeue.plug_idle(self, writable, readable)
===================================== gajim/conversation_textview.py ===================================== --- a/gajim/conversation_textview.py +++ b/gajim/conversation_textview.py @@ -60,10 +60,7 @@ log = logging.getLogger('gajim.conversation_textview')
def is_selection_modified(mark): name = mark.get_name() - if name and name in ('selection_bound', 'insert'): - return True - else: - return False + return name in ('selection_bound', 'insert')
def has_focus(widget): return widget.get_state_flags() & Gtk.StateFlags.FOCUSED == \ @@ -82,14 +79,12 @@ class TextViewImage(Gtk.Image):
def _get_selected(self): parent = self.get_parent() - if not parent or not self.anchor: return False + if not parent or not self.anchor: + return False buffer_ = parent.get_buffer() position = buffer_.get_iter_at_child_anchor(self.anchor) bounds = buffer_.get_selection_bounds() - if bounds and position.in_range(*bounds): - return True - else: - return False + return bounds and position.in_range(*bounds)
def get_state(self): parent = self.get_parent()
===================================== gajim/gtkgui_helpers.py ===================================== --- a/gajim/gtkgui_helpers.py +++ b/gajim/gtkgui_helpers.py @@ -266,10 +266,7 @@ def set_unset_urgency_hint(window, unread_messages_no): messages or not """ if app.config.get('use_urgency_hint'): - if unread_messages_no > 0: - window.props.urgency_hint = True - else: - window.props.urgency_hint = False + window.props.urgency_hint = unread_messages_no > 0
def get_pixbuf_from_data(file_data): """
===================================== gajim/plugins/pluginmanager.py ===================================== --- a/gajim/plugins/pluginmanager.py +++ b/gajim/plugins/pluginmanager.py @@ -629,7 +629,7 @@ class PluginManager(metaclass=Singleton): os.path.dirname(file_path))
for option in fields: - if conf.get('info', option) is '': + if conf.get('info', option) == '': raise configparser.NoOptionError(option, 'info') if option == 'description': setattr(module_attr, option, _(conf.get('info', option)))
===================================== gajim/remote_control.py ===================================== --- a/gajim/remote_control.py +++ b/gajim/remote_control.py @@ -90,7 +90,7 @@ class Server:
args = list(parameters.unpack()) for i, sig in enumerate(self.method_inargs[method_name]): - if sig is 'h': + if sig == 'h': msg = invocation.get_message() fd_list = msg.get_unix_fd_list() args[i] = fd_list.get(args[i])
===================================== gajim/tooltips.py ===================================== --- a/gajim/tooltips.py +++ b/gajim/tooltips.py @@ -139,11 +139,9 @@ class NotificationAreaTooltip(StatusTable): message = acct['message'] message = helpers.reduce_chars_newlines(message, 100, 1) message = GLib.markup_escape_text(message) - if acct['name'] in app.con_types and \ - app.con_types[acct['name']] in ('tls', 'ssl'): - show_lock = True - else: - show_lock = False + con_type = app.con_types.get(acct['name']) + show_lock = con_type in ('tls', 'ssl') + if message: self.add_status_row(file_path, acct['show'], GLib.markup_escape_text(acct['account_label']) + ' - ' + \ @@ -322,11 +320,9 @@ class RosterTooltip(Gtk.Window, StatusTable): message = acct['message'] message = helpers.reduce_chars_newlines(message, 100, 1) message = GLib.markup_escape_text(message) - if acct['name'] in app.con_types and \ - app.con_types[acct['name']] in ('tls', 'ssl'): - show_lock = True - else: - show_lock = False + con_type = app.con_types.get(acct['name']) + show_lock = con_type in ('tls', 'ssl') + if message: self.add_status_row(file_path, acct['show'], GLib.markup_escape_text(acct['account_label']) + ' - ' + \
===================================== scripts/dev/pre-push-tests.sh ===================================== --- a/scripts/dev/pre-push-tests.sh +++ b/scripts/dev/pre-push-tests.sh @@ -1,2 +1,2 @@ mypy -p gajim.common.modules --follow-imports=skip -pylint --jobs=2 --additional-builtins=_ --disable=all --enable=C0201,C0325,C1801,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0106,E0107,E0108,E0202,E0221,E0222,E0235,E0501,E0502,E0503,E0602,E0603,E0604,E0701,E0702,E1001,E1002,E1003,E1004,E1111,E1120,E1121,E1122,E1123,E1124,E1125,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701,R0205,W0102,W0611,W0612,W0621,W0702,W1201,W1202 gajim +pylint --jobs=2 --additional-builtins=_ --disable=all --enable=C0201,C0325,C1801,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0106,E0107,E0108,E0202,E0221,E0222,E0235,E0501,E0502,E0503,E0602,E0603,E0604,E0701,E0702,E1001,E1002,E1003,E1004,E1111,E1120,E1121,E1122,E1123,E1124,E1125,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701,R0123,R0205,R1703,W0102,W0611,W0612,W0621,W0702,W1201,W1202 gajim
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/76333ec73a4453f6ce33d006e711f302d4...