diff --git a/deluge/common.py b/deluge/common.py index af5bc920a..f46c98c3b 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -278,13 +278,13 @@ def fsize(fsize_b): """ # Bigger than 1 GiB - if (fsize_b >= 1073741824): + if fsize_b >= 1073741824: return "%.1f %s" % (fsize_b / 1073741824.0, gib_txt) # Bigger than 1 MiB - elif (fsize_b >= 1048576): + elif fsize_b >= 1048576: return "%.1f %s" % (fsize_b / 1048576.0, mib_txt) # Bigger than 1 KiB - elif (fsize_b >= 1024): + elif fsize_b >= 1024: return "%.1f %s" % (fsize_b / 1024.0, kib_txt) else: return "%d %s" % (fsize_b, byte_txt) @@ -744,7 +744,7 @@ class VersionSplit(object): """ # PEP 386 versions with .devN precede release version - if (bool(self.dev) != bool(ver.dev)): + if bool(self.dev) != bool(ver.dev): if self.dev != 'dev': self.dev = not self.dev if ver.dev != 'dev': diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py index 912789ee8..8c7cc75fd 100644 --- a/deluge/core/filtermanager.py +++ b/deluge/core/filtermanager.py @@ -257,13 +257,12 @@ class FilterManager(component.Component): return torrent_ids def _hide_state_items(self, state_items): - "for hide(show)-zero hits" + """For hide(show)-zero hits""" for (value, count) in state_items.items(): if value != "All" and count == 0: del state_items[value] def _sort_state_items(self, x, y): - "" if x[0] in STATE_SORT: ix = STATE_SORT.index(x[0]) else: diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 789b1c133..547ddd77b 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -840,7 +840,7 @@ class Torrent(object): parts = host.split(".") if len(parts) > 2: - if parts[-2] in ("co", "com", "net", "org") or parts[-1] in ("uk"): + if parts[-2] in ("co", "com", "net", "org") or parts[-1] == "uk": host = ".".join(parts[-3:]) else: host = ".".join(parts[-2:]) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index fe2f5e503..cb0508d93 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -516,7 +516,7 @@ class TorrentManager(component.Component): t_state_tmp = TorrentState() if dir(state.torrents[0]) != dir(t_state_tmp): try: - for attr in (set(dir(t_state_tmp)) - set(dir(state.torrents[0]))): + for attr in set(dir(t_state_tmp)) - set(dir(state.torrents[0])): for t_state in state.torrents: if attr == "storage_mode" and getattr(t_state, "compact", None): setattr(t_state, attr, "compact") diff --git a/deluge/event.py b/deluge/event.py index 6d9d4a81d..b916a5cee 100644 --- a/deluge/event.py +++ b/deluge/event.py @@ -22,7 +22,7 @@ class DelugeEventMetaClass(type): """ This metaclass simply keeps a list of all events classes created. """ - def __init__(self, name, bases, dct): + def __init__(self, name, bases, dct): # pylint: disable=bad-mcs-method-argument super(DelugeEventMetaClass, self).__init__(name, bases, dct) if name != "DelugeEvent": known_events[name] = self diff --git a/deluge/tests/common.py b/deluge/tests/common.py index d3bd6ccb2..3dfb44a8a 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -49,10 +49,10 @@ deluge.main.start_daemon() core = Popen([sys.executable], cwd=cwd, stdin=fp, stdout=PIPE, stderr=PIPE) while True: line = core.stderr.readline() - if ("starting on %d" % listen_port) in line: + if "starting on %d" % listen_port in line: time.sleep(0.3) # Slight pause just incase break - elif ("Couldn't listen on localhost:%d" % listen_port) in line: + elif "Couldn't listen on localhost:%d" % listen_port in line: raise CannotListenError("localhost", listen_port, "Could not start deluge test client: %s" % line) elif 'Traceback' in line: raise SystemExit( diff --git a/deluge/ui/Win32IconImagePlugin.py b/deluge/ui/Win32IconImagePlugin.py index e3ea2a80c..ef3762a22 100644 --- a/deluge/ui/Win32IconImagePlugin.py +++ b/deluge/ui/Win32IconImagePlugin.py @@ -212,7 +212,7 @@ class Win32IcoFile(object): # end Win32IcoFile -class Win32IconImageFile (PIL.ImageFile.ImageFile): +class Win32IconImageFile(PIL.ImageFile.ImageFile): """ PIL read-only image support for Microsoft .ico files. diff --git a/deluge/ui/console/main.py b/deluge/ui/console/main.py index 46ab99f07..bce728853 100644 --- a/deluge/ui/console/main.py +++ b/deluge/ui/console/main.py @@ -91,7 +91,7 @@ def start(): Console().start() -class DelugeHelpFormatter (optparse.IndentedHelpFormatter): +class DelugeHelpFormatter(optparse.IndentedHelpFormatter): """ Format help in a way suited to deluge Legacy mode - colors, format, indentation... """ diff --git a/deluge/ui/console/modes/add_util.py b/deluge/ui/console/modes/add_util.py index 75dea5bb7..e905f2193 100644 --- a/deluge/ui/console/modes/add_util.py +++ b/deluge/ui/console/modes/add_util.py @@ -22,10 +22,10 @@ log = logging.getLogger(__name__) def _bracket_fixup(path): - if (path.find("[") == -1 and path.find("]") == -1): + if path.find("[") == -1 and path.find("]") == -1: return path sentinal = 256 - while (path.find(unichr(sentinal)) != -1): + while path.find(unichr(sentinal)) != -1: sentinal += 1 if sentinal > 65535: log.error("Can't fix brackets in path, path contains all possible sentinal characters") @@ -42,8 +42,8 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress): t_options["download_location"] = os.path.expanduser(options["path"]) t_options["add_paused"] = options["add_paused"] - is_url = (not (options["path_type"] == 1)) and (deluge.common.is_url(t_file) or options["path_type"] == 2) - is_magnet = not(is_url) and (not (options["path_type"] == 1)) and deluge.common.is_magnet(t_file) + is_url = (not options["path_type"] == 1) and (deluge.common.is_url(t_file) or options["path_type"] == 2) + is_magnet = not(is_url) and (not options["path_type"] == 1) and deluge.common.is_magnet(t_file) if is_url or is_magnet: files = [t_file] diff --git a/deluge/ui/console/modes/alltorrents.py b/deluge/ui/console/modes/alltorrents.py index 8df754694..18ea2d751 100644 --- a/deluge/ui/console/modes/alltorrents.py +++ b/deluge/ui/console/modes/alltorrents.py @@ -387,17 +387,17 @@ class AllTorrents(BaseMode, component.Component): def __update_columns(self): self.column_widths = [self.config["%s_width" % c] for c in self.__cols_to_show] req = sum(filter(lambda x: x >= 0, self.column_widths)) - if (req > self.cols): # can't satisfy requests, just spread out evenly + if req > self.cols: # can't satisfy requests, just spread out evenly cw = int(self.cols / len(self.__columns)) for i in range(0, len(self.column_widths)): self.column_widths[i] = cw else: rem = self.cols - req var_cols = len(filter(lambda x: x < 0, self.column_widths)) - if (var_cols > 0): + if var_cols > 0: vw = int(rem / var_cols) for i in range(0, len(self.column_widths)): - if (self.column_widths[i] < 0): + if self.column_widths[i] < 0: self.column_widths[i] = vw self.column_string = "{!header!}" @@ -450,14 +450,14 @@ class AllTorrents(BaseMode, component.Component): def _scroll_up(self, by): prevoff = self.curoff self.cursel = max(self.cursel - by, 1) - if ((self.cursel - 1) < self.curoff): + if (self.cursel - 1) < self.curoff: self.curoff = max(self.cursel - 1, 1) return prevoff != self.curoff def _scroll_down(self, by): prevoff = self.curoff self.cursel = min(self.cursel + by, self.numtorrents) - if ((self.curoff + self.rows - 5) < self.cursel): + if (self.curoff + self.rows - 5) < self.cursel: self.curoff = self.cursel - self.rows + 5 return prevoff != self.curoff @@ -474,7 +474,7 @@ class AllTorrents(BaseMode, component.Component): return ret def _on_torrent_status(self, state): - if (self.popup): + if self.popup: self.popup.clear() name = state["name"] self.popup.set_title(name) @@ -589,7 +589,7 @@ class AllTorrents(BaseMode, component.Component): return result def _format_queue(self, qnum): - if (qnum >= 0): + if qnum >= 0: return "%d" % (qnum + 1) else: return "" @@ -963,7 +963,7 @@ class AllTorrents(BaseMode, component.Component): pass tidx += 1 currow += 1 - if (currow > (self.rows - 2)): + if currow > (self.rows - 2): break else: self.add_string(1, "Waiting for torrents from core...") @@ -1037,9 +1037,9 @@ class AllTorrents(BaseMode, component.Component): skip -= 1 continue self.cursel = (i + 1) - if ((self.curoff + self.rows - 5) < self.cursel): + if (self.curoff + self.rows - 5) < self.cursel: self.curoff = self.cursel - self.rows + 5 - elif ((self.curoff + 1) > self.cursel): + elif (self.curoff + 1) > self.cursel: self.curoff = max(1, self.cursel - 1) self.search_state = SEARCH_SUCCESS return diff --git a/deluge/ui/console/modes/column.py b/deluge/ui/console/modes/column.py index 81c0a7e89..494c460bf 100644 --- a/deluge/ui/console/modes/column.py +++ b/deluge/ui/console/modes/column.py @@ -16,7 +16,7 @@ log = logging.getLogger(__name__) def format_queue(qnum): - if (qnum >= 0): + if qnum >= 0: return "%d" % (qnum + 1) else: return "" diff --git a/deluge/ui/console/modes/format_utils.py b/deluge/ui/console/modes/format_utils.py index ee1ed539f..406445665 100644 --- a/deluge/ui/console/modes/format_utils.py +++ b/deluge/ui/console/modes/format_utils.py @@ -16,28 +16,28 @@ import deluge.common def format_speed(speed): - if (speed > 0): + if speed > 0: return deluge.common.fspeed(speed) else: return "-" def format_time(time): - if (time > 0): + if time > 0: return deluge.common.ftime(time) else: return "-" def format_date(time): - if (time > 0): + if time > 0: return deluge.common.fdate(time) else: return "" def format_date_never(time): - if (time > 0): + if time > 0: return deluge.common.fdate(time) else: return "Never" @@ -112,7 +112,7 @@ def format_column(col, lim): col = ud_normalize("NFC", col) dbls = sum(east_asian_width(c) in "WF" for c in col) size = len(col) + dbls - if (size >= lim - 1): + if size >= lim - 1: return trim_string(col, lim, dbls > 0) else: return "%s%s" % (col, " " * (lim - size)) diff --git a/deluge/ui/console/modes/input_popup.py b/deluge/ui/console/modes/input_popup.py index 208052887..5a69b0288 100644 --- a/deluge/ui/console/modes/input_popup.py +++ b/deluge/ui/console/modes/input_popup.py @@ -503,7 +503,7 @@ class FloatSpinInput(InputField): self.need_update = True # Move the cursor forward self.cursor += 1 - elif (c > 47 and c < 58): + elif c > 47 and c < 58: if (not self.real_value) and self.valstr: self.valstr = "" self.cursor = 0 @@ -875,7 +875,7 @@ class InputPopup(Popup): crow += 1 crow += ipt.render(self.screen, crow, self.width, i == self.current_input) - if (self.content_height > (self.height - 2)): + if self.content_height > (self.height - 2): lts = self.content_height - (self.height - 3) perc_sc = float(self.lineoff) / lts sb_pos = int((self.height - 2) * perc_sc) + 1 diff --git a/deluge/ui/console/modes/popup.py b/deluge/ui/console/modes/popup.py index 41d258308..42b5e3103 100644 --- a/deluge/ui/console/modes/popup.py +++ b/deluge/ui/console/modes/popup.py @@ -77,7 +77,7 @@ class Popup: def _refresh_lines(self): crow = 1 for line in self._lines[self.lineoff:]: - if (crow >= self.height - 1): + if crow >= self.height - 1: break self.parent.add_string(crow, line, self.screen, 1, False, True) crow += 1 @@ -137,7 +137,7 @@ class Popup: self.parent.add_string(0, "{!white,black,bold!}%s" % self.title, self.screen, toff, False, True) self._refresh_lines() - if (len(self._lines) > (self.height - 2)): + if len(self._lines) > (self.height - 2): lts = len(self._lines) - (self.height - 3) perc_sc = float(self.lineoff) / lts sb_pos = int((self.height - 2) * perc_sc) + 1 @@ -232,9 +232,9 @@ class SelectablePopup(Popup): def _refresh_lines(self): crow = 1 for row, line in enumerate(self._lines): - if (crow >= self.height - 1): + if crow >= self.height - 1: break - if (row < self.lineoff): + if row < self.lineoff: continue fg = self._line_foregrounds[row] udx = self._udxs.get(crow) @@ -284,7 +284,7 @@ class SelectablePopup(Popup): def _move_cursor_down(self, amount): idx = self._selectable_lines.index(self._selected) - if (idx < len(self._selectable_lines) - amount): + if idx < len(self._selectable_lines) - amount: self._selected = self._selectable_lines[idx + amount] else: self._selected = self._selectable_lines[-1] diff --git a/deluge/ui/console/modes/torrentdetail.py b/deluge/ui/console/modes/torrentdetail.py index d4ba4d00d..7c389d579 100644 --- a/deluge/ui/console/modes/torrentdetail.py +++ b/deluge/ui/console/modes/torrentdetail.py @@ -225,7 +225,7 @@ class TorrentDetail(BaseMode, component.Component): def __update_columns(self): self.column_widths = [-1, 15, 15, 20] req = sum(filter(lambda x: x >= 0, self.column_widths)) - if (req > self.cols): # can't satisfy requests, just spread out evenly + if req > self.cols: # can't satisfy requests, just spread out evenly cw = int(self.cols / len(self.column_names)) for i in range(0, len(self.column_widths)): self.column_widths[i] = cw @@ -234,7 +234,7 @@ class TorrentDetail(BaseMode, component.Component): var_cols = len(filter(lambda x: x < 0, self.column_widths)) vw = int(rem / var_cols) for i in range(0, len(self.column_widths)): - if (self.column_widths[i] < 0): + if self.column_widths[i] < 0: self.column_widths[i] = vw self.column_string = "{!green,black,bold!}%s" % ("".join(["%s%s" % (self.column_names[i], " " * ( @@ -287,7 +287,7 @@ class TorrentDetail(BaseMode, component.Component): # from sys import stderr # print >> stderr, fl[6] # kick out if we're going to draw too low on the screen - if (off >= self.rows - 1): + if off >= self.rows - 1: self.more_to_draw = True return -1, -1 diff --git a/deluge/ui/gtkui/path_combo_chooser.py b/deluge/ui/gtkui/path_combo_chooser.py index a43fb9c45..a35a19616 100755 --- a/deluge/ui/gtkui/path_combo_chooser.py +++ b/deluge/ui/gtkui/path_combo_chooser.py @@ -524,14 +524,14 @@ class PathChooserPopup(object): """ # Entry is not yet visible - if not (self.path_entry.flags() & gtk.REALIZED): + if not self.path_entry.flags() & gtk.REALIZED: return self.set_window_position_and_size() def popdown(self): if not self.is_popped_up(): return - if not (self.path_entry.flags() & gtk.REALIZED): + if not self.path_entry.flags() & gtk.REALIZED: return self.popup_window.grab_remove() self.popup_window.hide_all() @@ -751,7 +751,7 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup): PathChooserPopup.popup(self) self.popup_window.grab_focus() - if not (self.treeview.flags() & gtk.HAS_FOCUS): + if not self.treeview.flags() & gtk.HAS_FOCUS: self.treeview.grab_focus() if not self.popup_grab_window(): self.popup_window.hide() @@ -874,7 +874,7 @@ class PathCompletionPopup(CompletionList, PathChooserPopup): PathChooserPopup.popup(self) self.popup_window.grab_focus() - if not (self.treeview.flags() & gtk.HAS_FOCUS): + if not self.treeview.flags() & gtk.HAS_FOCUS: self.treeview.grab_focus() if not self.popup_grab_window(): @@ -931,7 +931,7 @@ class PathAutoCompleter(object): self.accelerator_string = gtk.accelerator_name(keysyms.Tab, 0) def on_entry_text_insert_text(self, entry, new_text, new_text_length, position): - if (self.path_entry.flags() & gtk.REALIZED): + if self.path_entry.flags() & gtk.REALIZED: cur_text = self.path_entry.get_text() pos = entry.get_position() new_complete_text = cur_text[:pos] + new_text + cur_text[pos:] diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index 12ade318f..26be635b5 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -364,11 +364,9 @@ class StatusBar(component.Component): self.traffic_item.set_text(label_string) def update(self): - # Send status request self.send_status_request() def set_limit_value(self, widget, core_key): - """ """ log.debug("_on_set_unlimit_other %s", core_key) other_dialog_info = { "max_download_speed": (_("Download Speed Limit"), _("Set the maximum download speed"), diff --git a/pylintrc b/pylintrc index be9fdba09..014f369b9 100644 --- a/pylintrc +++ b/pylintrc @@ -22,7 +22,7 @@ persistent=yes load-plugins= # Use multiple processes to speed up Pylint. -jobs=1 +jobs=2 # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. @@ -62,16 +62,14 @@ 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=E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625, -# W1624,W1609,W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020, -# W1618,W1619,W1630,W1626,W1637,W1634,W1635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617, -# W1632,W1633,W0704,W1628,W1629,W1636 -disable=C, +# +# Arranged by category (convention, error, information, refactor, warning). +# One category per line using symbolic names instead of ids. +disable=missing-docstring, invalid-name, old-style-class, bad-continuation, no-member, not-callable, no-name-in-module, - W, + locally-disabled, R, - locally-disabled - + W [REPORTS] @@ -130,7 +128,7 @@ required-attributes= bad-functions=map,filter,input # Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ +good-names=d,i,j,k,ex,Run,_,log # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata @@ -234,7 +232,7 @@ single-line-if-stmt=no no-space-check=trailing-comma,dict-separator # Maximum number of lines in a module -max-module-lines=1500 +max-module-lines=1550 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 # tab).