Philipp Hörist pushed to branch master at gajim / gajim
Commits: 8ca9c1d6 by Philipp Hörist at 2019-04-07T17:04:21Z Add description for some pylint errors
- - - - - dc3910ce by Philipp Hörist at 2019-04-07T17:07:16Z Fix useless-return pylint errors
- - - - - 20d3e981 by Philipp Hörist at 2019-04-07T17:48:09Z Fix consider-using-ternary pylint errors
- - - - - ee38f760 by Philipp Hörist at 2019-04-07T17:50:15Z Fix chained-comparison pylint errors
- - - - - 1c39d66d by Philipp Hörist at 2019-04-07T18:13:55Z Fix assignment-from-none pylint errors
- - - - - f62f9227 by Philipp Hörist at 2019-04-07T18:27:07Z Fix unused-wildcard-import pylint errors
- - - - - d55cb97d by Philipp Hörist at 2019-04-07T18:41:27Z Update pylintrc
- Ignore some pylint errors only in CI, not locally - Set max line length to 80
- - - - -
12 changed files:
- gajim/chat_control_base.py - gajim/common/optparser.py - gajim/common/protocol/bytestream.py - gajim/common/socks5.py - gajim/common/zeroconf/zeroconf_avahi.py - gajim/common/zeroconf/zeroconf_avahi_const.py - gajim/dialogs.py - gajim/gui_interface.py - gajim/message_window.py - gajim/roster_window.py - pylintrc - scripts/dev/pylint-ci.sh
Changes:
===================================== gajim/chat_control_base.py ===================================== @@ -497,7 +497,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): item = Gtk.SeparatorMenuItem.new() menu.prepend(item)
- menu2 = self.prepare_context_menu() + menu2 = self.prepare_context_menu() # pylint: disable=assignment-from-none i = 0 for item in menu2: menu2.remove(item)
===================================== gajim/common/optparser.py ===================================== @@ -113,14 +113,16 @@ class OptionsParser: app.config.foreach(self.write_line, file) except IOError: log.exception('Failed to write config file') - return + return False
try: temp_filepath.replace(config_path) except Exception: log.exception('Failed to replace config file') - else: - log.info('Successful saved config file') + return False + + log.info('Successful saved config file') + return True
def update_config(self, old_version, new_version): old_version_list = old_version.split('.') # convert '0.x.y' to (0, x, y)
===================================== gajim/common/protocol/bytestream.py ===================================== @@ -563,7 +563,6 @@ class ConnectionSocks5Bytestream(ConnectionBytestream): """ file_props = FilesProp.getFilePropBySid(sid) file_props.hash_ = hash_id - return
def _connect_error(self, sid, error, error_type, msg=None): """
===================================== gajim/common/socks5.py ===================================== @@ -1297,8 +1297,7 @@ class Socks5Client(Socks5): return if self.state < 5: self.idlequeue.set_read_timeout(self.fd, CONNECT_TIMEOUT) - result = self.main(0) - self.queue.process_result(result, self) + self.main(0) elif self.state == 5: # wait for proxy reply pass elif self.file_props.type_ == 'r':
===================================== gajim/common/zeroconf/zeroconf_avahi.py ===================================== @@ -15,17 +15,25 @@ # along with Gajim. If not, see http://www.gnu.org/licenses/.
import logging -log = logging.getLogger('gajim.c.z.zeroconf_avahi')
-import gi -gi.require_version('Avahi', '0.6') from gi.repository import Avahi from gi.repository import Gio from gi.repository import GLib
from gajim.common.i18n import _ from gajim.common.zeroconf.zeroconf import Constant, ConstantRI -from gajim.common.zeroconf.zeroconf_avahi_const import * +from gajim.common.zeroconf.zeroconf_avahi_const import DBUS_NAME +from gajim.common.zeroconf.zeroconf_avahi_const import DBUS_INTERFACE_SERVER +from gajim.common.zeroconf.zeroconf_avahi_const import DBUS_INTERFACE_ENTRY_GROUP +from gajim.common.zeroconf.zeroconf_avahi_const import DBUS_INTERFACE_DOMAIN_BROWSER +from gajim.common.zeroconf.zeroconf_avahi_const import ServerState +from gajim.common.zeroconf.zeroconf_avahi_const import EntryGroup +from gajim.common.zeroconf.zeroconf_avahi_const import DomainBrowser +from gajim.common.zeroconf.zeroconf_avahi_const import Protocol +from gajim.common.zeroconf.zeroconf_avahi_const import Interface + +log = logging.getLogger('gajim.c.z.zeroconf_avahi') +
class Zeroconf: def __init__(self, new_serviceCB, remove_serviceCB, name_conflictCB,
===================================== gajim/common/zeroconf/zeroconf_avahi_const.py ===================================== @@ -20,15 +20,8 @@ from enum import IntEnum
DBUS_NAME = "org.freedesktop.Avahi" DBUS_INTERFACE_SERVER = DBUS_NAME + ".Server" -DBUS_PATH_SERVER = "/" DBUS_INTERFACE_ENTRY_GROUP = DBUS_NAME + ".EntryGroup" DBUS_INTERFACE_DOMAIN_BROWSER = DBUS_NAME + ".DomainBrowser" -DBUS_INTERFACE_SERVICE_TYPE_BROWSER = DBUS_NAME + ".ServiceTypeBrowser" -DBUS_INTERFACE_SERVICE_BROWSER = DBUS_NAME + ".ServiceBrowser" -DBUS_INTERFACE_ADDRESS_RESOLVER = DBUS_NAME + ".AddressResolver" -DBUS_INTERFACE_HOST_NAME_RESOLVER = DBUS_NAME + ".HostNameResolver" -DBUS_INTERFACE_SERVICE_RESOLVER = DBUS_NAME + ".ServiceResolver" -DBUS_INTERFACE_RECORD_BROWSER = DBUS_NAME + ".RecordBrowser"
class ServerState(IntEnum):
===================================== gajim/dialogs.py ===================================== @@ -50,8 +50,10 @@ from gajim.common import i18n from gajim.common.modules import dataforms from gajim.common.exceptions import GajimGeneralException
-# Compat with Gajim 1.0.3 for plugins -from gajim.gtk.dialogs import * +from gajim.gtk.dialogs import ErrorDialog +from gajim.gtk.dialogs import ConfirmationDialog +from gajim.gtk.dialogs import InputDialog +from gajim.gtk.dialogs import InformationDialog from gajim.gtk.util import get_icon_name from gajim.gtk.util import resize_window from gajim.gtk.util import get_builder @@ -1399,9 +1401,6 @@ class Dialog(Gtk.Dialog): def just_destroy(self, widget): self.destroy()
- def get_button(self, index): - buttons = self.get_action_area().get_children() - return index < len(buttons) and buttons[index] or None
class DataFormWindow(Dialog): def __init__(self, form, on_response_ok):
===================================== gajim/gui_interface.py ===================================== @@ -2038,15 +2038,12 @@ class Interface:
@staticmethod def save_config(): - err_str = parser.write() - if err_str is not None: - print(err_str, file=sys.stderr) - # it is good to notify the user - # in case he or she cannot see the output of the console - error_dialog = ErrorDialog(_('Could not save your settings and ' - 'preferences'), err_str) - error_dialog.run() - sys.exit() + if parser.write(): + return + + error_dialog = ErrorDialog( + _('Could not save your settings and preferences')) + error_dialog.run()
@staticmethod def update_avatar(account=None, jid=None, contact=None, room_avatar=False):
===================================== gajim/message_window.py ===================================== @@ -890,15 +890,13 @@ class MessageWindow: tab = self.notebook.get_tab_label(page) tab_alloc = tab.get_allocation() if horiz: - if (x >= tab_alloc.x) and \ - (x <= (tab_alloc.x + tab_alloc.width)): + if tab_alloc.x <= x <= (tab_alloc.x + tab_alloc.width): page_num = i if x >= tab_alloc.x + (tab_alloc.width / 2.0): to_right = True break else: - if (y >= tab_alloc.y) and \ - (y <= (tab_alloc.y + tab_alloc.height)): + if tab_alloc.y <= y <= (tab_alloc.y + tab_alloc.height): page_num = i
if y > tab_alloc.y + (tab_alloc.height / 2.0):
===================================== gajim/roster_window.py ===================================== @@ -3308,7 +3308,7 @@ class RosterWindow: not event.get_state() & Gdk.ModifierType.CONTROL_MASK): # Don't handle double click if we press icon of a metacontact titer = model.get_iter(path) - if x > x_min and x < x_min + 27 and type_ == 'contact' and \ + if x_min < x < x_min + 27 and type_ == 'contact' and \ model.iter_has_child(titer): if self.tree.row_expanded(path): self.tree.collapse_row(path) @@ -3328,7 +3328,7 @@ class RosterWindow: else: self.expand_group_row(path)
- elif type_ == 'contact' and x > x_min and x < x_min + 27: + elif type_ == 'contact' and x_min < x < x_min + 27: if self.tree.row_expanded(path): self.tree.collapse_row(path) else: @@ -4461,8 +4461,9 @@ class RosterWindow: return
# Is the contact we drag a meta contact? - accounts = (self.regroup and app.contacts.get_accounts()) or \ - account_source + accounts = account_source + if self.regroup: + accounts = app.contacts.get_accounts() or account_source is_big_brother = app.contacts.is_big_brother(account_source, jid_source, accounts)
===================================== pylintrc ===================================== @@ -50,7 +50,9 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=C0111,C0301,R1710,R0912,R0914,R0915,W0511,W0231,W0233 +# C0111 missing-docstring +# W0511 fix-me +disable=C0111,W0511
# Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -220,7 +222,7 @@ indent-after-paren=4 indent-string=' '
# Maximum number of characters on a single line. -max-line-length=100 +max-line-length=80
# Maximum number of lines in a module max-module-lines=1000
===================================== scripts/dev/pylint-ci.sh ===================================== @@ -1,9 +1,10 @@ #!/bin/sh PYLINT=${PYLINT:-pylint}
-"$PYLINT" --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,W0201,W0212,W0221,W0223,W0311,W0401,W0603,W0613,W0614 "$@" +"$PYLINT" --disable=C0103,C0302,C0301,C0330,C0411,C0412,C0413,E0203,E0401,E0611,E0710,E0712,E1101,E1102,E1133,E1136,R0201,R0901,R0904,R0912,R0913,R0914,R0915,R0916,R1702,R1710,W0201,W0212,W0221,W0223,W0231,W0233,W0311,W0401,W0603,W0613 "$@"
# C0103 invalid-name +# C0301 line-too-long # C0302 too-many-lines # C0330 bad-continuation # C0411 wrong-import-order @@ -16,24 +17,25 @@ PYLINT=${PYLINT:-pylint} # E0712 catching-non-exception - GLib.GError is not recognized # E1101 no-member # E1102 not-callable -# E1128 assignment-from-none # E1133 not-an-iterable # E1136 unsubscriptable-object # R0201 no-self-use # R0901 too-many-ancestors # R0904 too-many-public-methods # R0913 too-many-arguments +# R0912 too-many-branches +# R0914 too-many-locals +# R0915 too-many-statements # R0916 too-many-boolean-expressions -# R1702 -# R1706 -# R1711 -# R1716 +# R1702 too-many-nested-blocks +# R1710 inconsistent-return-statements # W0201 attribute-defined-outside-init # W0212 protected-access # W0221 arguments-differ # W0223 abstract-method +# W0231 super-init-not-called +# W0233 non-parent-init-called # W0311 bad-indentation # W0401 wildcard-import # W0603 global-statement # W0613 unused-argument -# W0614 unused-wildcard-import
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/5471980a8cce499509d323f3423cebec9a...