diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3a347fd98..6c55c6b77 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 - name: Run pre-commit linting - uses: pre-commit/action@v2.0.2 + uses: pre-commit/action@v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5293315b2..4d0d922ef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,12 +7,12 @@ exclude: > )$ repos: - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 23.1.0 hooks: - id: black name: Fmt Black - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.5.1 + rev: v2.7.1 hooks: - id: prettier name: Fmt Prettier @@ -24,14 +24,14 @@ repos: - id: isort name: Fmt isort - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 6.0.0 hooks: - id: flake8 name: Chk Flake8 additional_dependencies: - pep8-naming==0.12.1 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.4.0 hooks: - id: double-quote-string-fixer name: Fix Double-quotes @@ -44,7 +44,7 @@ repos: - id: trailing-whitespace name: Fix Trailing whitespace - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v3.3.1 hooks: - id: pyupgrade args: [--py36-plus] diff --git a/deluge/bencode.py b/deluge/bencode.py index b012ca097..df8cc85c2 100644 --- a/deluge/bencode.py +++ b/deluge/bencode.py @@ -85,7 +85,6 @@ def bdecode(x): class Bencached: - __slots__ = ['bencoded'] def __init__(self, s): diff --git a/deluge/common.py b/deluge/common.py index ecf90a390..bcee2695f 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -875,7 +875,7 @@ def get_path_size(path): return os.path.getsize(path) dir_size = 0 - for (p, dummy_dirs, files) in os.walk(path): + for p, dummy_dirs, files in os.walk(path): for _file in files: filename = os.path.join(p, _file) dir_size += os.path.getsize(filename) diff --git a/deluge/core/alertmanager.py b/deluge/core/alertmanager.py index 9a1ded52e..d2017aec4 100644 --- a/deluge/core/alertmanager.py +++ b/deluge/core/alertmanager.py @@ -90,7 +90,7 @@ class AlertManager(component.Component): :param handler: func, the handler function to deregister """ # Iterate through all handlers and remove 'handler' where found - for (dummy_key, value) in self.handlers.items(): + for dummy_key, value in self.handlers.items(): if handler in value: # Handler is in this alert type list value.remove(handler) diff --git a/deluge/core/core.py b/deluge/core/core.py index 35cf0194f..d5d95a3ac 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -1000,7 +1000,6 @@ class Core(component.Component): trackers, add_to_session, ): - log.debug('creating torrent..') threading.Thread( target=self._create_torrent_thread, diff --git a/deluge/decorators.py b/deluge/decorators.py index 2f9fcd7d3..92e3ecf59 100644 --- a/deluge/decorators.py +++ b/deluge/decorators.py @@ -166,7 +166,8 @@ def deprecated(func): class CoroutineDeferred(defer.Deferred): """Wraps a coroutine in a Deferred. - It will dynamically pass through the underlying coroutine without wrapping where apporpriate.""" + It will dynamically pass through the underlying coroutine without wrapping where apporpriate. + """ def __init__(self, coro: Coroutine): # Delay this import to make sure a reactor was installed first diff --git a/deluge/i18n/util.py b/deluge/i18n/util.py index df2e3ab8a..f6920fbb3 100644 --- a/deluge/i18n/util.py +++ b/deluge/i18n/util.py @@ -51,7 +51,7 @@ def get_languages(): name = LANGUAGES[lang_code] lang.append([lang_code, _(name)]) - lang = sorted(lang, key=lambda l: l[1]) + lang = sorted(lang, key=lambda k: k[1]) return lang diff --git a/deluge/maketorrent.py b/deluge/maketorrent.py index c0051cae0..07a2a9d17 100644 --- a/deluge/maketorrent.py +++ b/deluge/maketorrent.py @@ -117,7 +117,7 @@ class TorrentMetadata: files = [] padding_count = 0 # Collect a list of file paths and add padding files if necessary - for (dirpath, dirnames, filenames) in os.walk(self.data_path): + for dirpath, dirnames, filenames in os.walk(self.data_path): for index, filename in enumerate(filenames): size = get_path_size( os.path.join(self.data_path, dirpath, filename) diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/core.py b/deluge/plugins/AutoAdd/deluge_autoadd/core.py index 9b6eee098..271d5f0d9 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/core.py @@ -80,7 +80,6 @@ def check_input(cond, message): class Core(CorePluginBase): def enable(self): - # reduce typing, assigning some values to self... self.config = deluge.configmanager.ConfigManager('autoadd.conf', DEFAULT_PREFS) self.config.run_converter((0, 1), 2, self.__migrate_config_1_to_2) diff --git a/deluge/plugins/Blocklist/deluge_blocklist/webui.py b/deluge/plugins/Blocklist/deluge_blocklist/webui.py index b8a0ca244..8ba49117d 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/webui.py +++ b/deluge/plugins/Blocklist/deluge_blocklist/webui.py @@ -23,6 +23,5 @@ FORMAT_LIST = [ class WebUI(WebPluginBase): - scripts = [get_resource('blocklist.js')] debug_scripts = scripts diff --git a/deluge/plugins/Execute/deluge_execute/webui.py b/deluge/plugins/Execute/deluge_execute/webui.py index 26a444533..3586371a7 100644 --- a/deluge/plugins/Execute/deluge_execute/webui.py +++ b/deluge/plugins/Execute/deluge_execute/webui.py @@ -16,6 +16,5 @@ log = logging.getLogger(__name__) class WebUI(WebPluginBase): - scripts = [get_resource('execute.js')] debug_scripts = scripts diff --git a/deluge/plugins/Extractor/deluge_extractor/webui.py b/deluge/plugins/Extractor/deluge_extractor/webui.py index 715733cb7..0f58658d9 100644 --- a/deluge/plugins/Extractor/deluge_extractor/webui.py +++ b/deluge/plugins/Extractor/deluge_extractor/webui.py @@ -20,6 +20,5 @@ log = logging.getLogger(__name__) class WebUI(WebPluginBase): - scripts = [get_resource('extractor.js')] debug_scripts = scripts diff --git a/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py b/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py index da1830269..9d164b284 100644 --- a/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py +++ b/deluge/plugins/Label/deluge_label/gtkui/sidebar_menu.py @@ -31,7 +31,6 @@ NO_LABEL = 'No Label' # menu class LabelSidebarMenu: def __init__(self): - self.treeview = component.get('FilterTreeView') self.menu = self.treeview.menu self.items = [] diff --git a/deluge/plugins/Notifications/deluge_notifications/webui.py b/deluge/plugins/Notifications/deluge_notifications/webui.py index ad090f5c1..bf3e829d2 100644 --- a/deluge/plugins/Notifications/deluge_notifications/webui.py +++ b/deluge/plugins/Notifications/deluge_notifications/webui.py @@ -21,7 +21,6 @@ log = logging.getLogger(__name__) class WebUI(WebPluginBase): - scripts = [get_resource('notifications.js')] debug_scripts = scripts diff --git a/deluge/plugins/Scheduler/deluge_scheduler/webui.py b/deluge/plugins/Scheduler/deluge_scheduler/webui.py index 4f5418b88..e41791638 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/webui.py +++ b/deluge/plugins/Scheduler/deluge_scheduler/webui.py @@ -19,6 +19,5 @@ log = logging.getLogger(__name__) class WebUI(WebPluginBase): - scripts = [get_resource('scheduler.js')] debug_scripts = scripts diff --git a/deluge/plugins/Stats/deluge_stats/webui.py b/deluge/plugins/Stats/deluge_stats/webui.py index f38daeb64..2c2ed469c 100644 --- a/deluge/plugins/Stats/deluge_stats/webui.py +++ b/deluge/plugins/Stats/deluge_stats/webui.py @@ -20,7 +20,6 @@ log = logging.getLogger(__name__) class WebUI(WebPluginBase): - scripts = [get_resource('stats.js')] # The enable and disable methods are not scrictly required on the WebUI diff --git a/deluge/plugins/Toggle/deluge_toggle/webui.py b/deluge/plugins/Toggle/deluge_toggle/webui.py index d16d29fff..637365ca7 100644 --- a/deluge/plugins/Toggle/deluge_toggle/webui.py +++ b/deluge/plugins/Toggle/deluge_toggle/webui.py @@ -21,7 +21,6 @@ log = logging.getLogger(__name__) class WebUI(WebPluginBase): - scripts = [get_resource('toggle.js')] def enable(self): diff --git a/deluge/plugins/pluginbase.py b/deluge/plugins/pluginbase.py index 5dda2f077..58162feab 100644 --- a/deluge/plugins/pluginbase.py +++ b/deluge/plugins/pluginbase.py @@ -14,7 +14,6 @@ log = logging.getLogger(__name__) class PluginBase(component.Component): - update_interval = 1 def __init__(self, name): @@ -57,7 +56,6 @@ class Gtk3PluginBase(PluginBase): class WebPluginBase(PluginBase): - scripts = [] debug_scripts = [] diff --git a/deluge/scripts/create_plugin.py b/deluge/scripts/create_plugin.py index 266747b94..7383661ea 100644 --- a/deluge/scripts/create_plugin.py +++ b/deluge/scripts/create_plugin.py @@ -49,7 +49,6 @@ options = parser.parse_args() def create_plugin(): - if not options.url: options.url = '' diff --git a/deluge/tests/test_rpcserver.py b/deluge/tests/test_rpcserver.py index 982d1d5f1..77c9f1e9b 100644 --- a/deluge/tests/test_rpcserver.py +++ b/deluge/tests/test_rpcserver.py @@ -19,7 +19,6 @@ setup_logger('none') class DelugeRPCProtocolTester(DelugeRPCProtocol): - messages = [] def transfer_message(self, data): diff --git a/deluge/tests/test_security.py b/deluge/tests/test_security.py index e3e434433..6627b6956 100644 --- a/deluge/tests/test_security.py +++ b/deluge/tests/test_security.py @@ -46,7 +46,6 @@ class SecurityBaseTestCase: ) def on_result(results): - if test == '-e': results = results[0].split(b'\n')[7:-6] assert len(results) > 3 diff --git a/deluge/tests/test_torrentview.py b/deluge/tests/test_torrentview.py index 8d0568866..9da99d849 100644 --- a/deluge/tests/test_torrentview.py +++ b/deluge/tests/test_torrentview.py @@ -35,7 +35,6 @@ setup_translation() @pytest.mark.gtkui class TestTorrentview(BaseTestCase): - default_column_index = [ 'filter', 'torrent_id', diff --git a/deluge/tests/test_webserver.py b/deluge/tests/test_webserver.py index e1588fdf3..dd3b9ea58 100644 --- a/deluge/tests/test_webserver.py +++ b/deluge/tests/test_webserver.py @@ -25,7 +25,6 @@ common.disable_new_release_check() class TestWebServer(WebServerTestBase, WebServerMockBase): @pytest_twisted.inlineCallbacks def test_get_torrent_info(self): - agent = Agent(reactor) self.mock_authentication_ignore(self.deluge_web.auth) diff --git a/deluge/ui/console/cmdline/command.py b/deluge/ui/console/cmdline/command.py index 40edd78f0..63dc9265a 100644 --- a/deluge/ui/console/cmdline/command.py +++ b/deluge/ui/console/cmdline/command.py @@ -142,7 +142,6 @@ class Commander: class BaseCommand: - usage = None interactive_only = False aliases = [] diff --git a/deluge/ui/console/console.py b/deluge/ui/console/console.py index 8ef87e8de..f91563f43 100644 --- a/deluge/ui/console/console.py +++ b/deluge/ui/console/console.py @@ -61,7 +61,6 @@ class LogStream: class Console(UI): - cmd_description = """Console or command-line user interface""" def __init__(self, *args, **kwargs): diff --git a/deluge/ui/console/modes/torrentdetail.py b/deluge/ui/console/modes/torrentdetail.py index 16bd08a5c..4383d58a6 100644 --- a/deluge/ui/console/modes/torrentdetail.py +++ b/deluge/ui/console/modes/torrentdetail.py @@ -181,7 +181,6 @@ class TorrentDetail(BaseMode, PopupsHandler): self.refresh() def set_state(self, state): - if state.get('files'): self.full_names = {x['index']: x['path'] for x in state['files']} @@ -363,7 +362,6 @@ class TorrentDetail(BaseMode, PopupsHandler): ).addCallback(self.set_state) def draw_files(self, files, depth, off, idx): - color_selected = 'blue' color_partially_selected = 'magenta' color_highlighted = 'white' diff --git a/deluge/ui/console/modes/torrentlist/torrentactions.py b/deluge/ui/console/modes/torrentlist/torrentactions.py index 6450118c6..a153e1154 100644 --- a/deluge/ui/console/modes/torrentlist/torrentactions.py +++ b/deluge/ui/console/modes/torrentlist/torrentactions.py @@ -240,7 +240,6 @@ def torrent_action(action, *args, **kwargs): # Creates the popup. mode is the calling mode, tids is a list of torrents to take action upon def torrent_actions_popup(mode, torrent_ids, details=False, action=None, close_cb=None): - if action is not None: torrent_action(action, mode=mode, torrent_ids=torrent_ids) return diff --git a/deluge/ui/console/widgets/popup.py b/deluge/ui/console/widgets/popup.py index 4b0d0274e..90ecaaf06 100644 --- a/deluge/ui/console/widgets/popup.py +++ b/deluge/ui/console/widgets/popup.py @@ -130,7 +130,6 @@ class Popup(BaseWindow, InputKeyHandler): BaseWindow.refresh(self) def calculate_size(self): - if isinstance(self.height_req, float) and 0.0 < self.height_req <= 1.0: height = int((self.parent.rows - 2) * self.height_req) else: diff --git a/deluge/ui/gtk3/__init__.py b/deluge/ui/gtk3/__init__.py index 8db2773e4..d1b4ec53f 100644 --- a/deluge/ui/gtk3/__init__.py +++ b/deluge/ui/gtk3/__init__.py @@ -18,7 +18,6 @@ environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1' # Keep this class in __init__.py to avoid the console having to import everything in gtkui.py class Gtk(UI): - cmd_description = """GTK-based graphical user interface""" def __init__(self, *args, **kwargs): diff --git a/deluge/ui/gtk3/files_tab.py b/deluge/ui/gtk3/files_tab.py index 24c169727..6e0fba417 100644 --- a/deluge/ui/gtk3/files_tab.py +++ b/deluge/ui/gtk3/files_tab.py @@ -245,7 +245,7 @@ class FilesTab(Tab): if state['sort_id'] is not None and state['sort_order'] is not None: self.treestore.set_sort_column_id(state['sort_id'], state['sort_order']) - for (index, column) in enumerate(self.listview.get_columns()): + for index, column in enumerate(self.listview.get_columns()): cname = column.get_title() if cname in state['columns']: cstate = state['columns'][cname] @@ -759,7 +759,6 @@ class FilesTab(Tab): fd['path'] = fd['path'].replace(old_folder, new_folder, 1) if torrent_id == self.torrent_id: - old_split = old_folder.split('/') try: old_split.remove('') diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py index d11ff317a..e1e3bb342 100644 --- a/deluge/ui/gtk3/mainwindow.py +++ b/deluge/ui/gtk3/mainwindow.py @@ -44,7 +44,6 @@ log = logging.getLogger(__name__) class _GtkBuilderSignalsHolder: def connect_signals(self, mapping_or_class): - if isinstance(mapping_or_class, dict): for name, handler in mapping_or_class.items(): if hasattr(self, name): diff --git a/deluge/ui/gtk3/path_combo_chooser.py b/deluge/ui/gtk3/path_combo_chooser.py index 74d9055b7..aeb4c7a9e 100755 --- a/deluge/ui/gtk3/path_combo_chooser.py +++ b/deluge/ui/gtk3/path_combo_chooser.py @@ -62,7 +62,6 @@ def path_without_trailing_path_sep(path): class ValueList: - paths_without_trailing_path_sep = False def get_values_count(self): @@ -1097,7 +1096,6 @@ class PathAutoCompleter: class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject): - __gsignals__ = { signal: (SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,)) for signal in [ diff --git a/deluge/ui/gtk3/peers_tab.py b/deluge/ui/gtk3/peers_tab.py index b458f7a7d..5768fbe3c 100644 --- a/deluge/ui/gtk3/peers_tab.py +++ b/deluge/ui/gtk3/peers_tab.py @@ -186,7 +186,7 @@ class PeersTab(Tab): if state['sort_id'] and state['sort_order'] is not None: self.liststore.set_sort_column_id(state['sort_id'], state['sort_order']) - for (index, column) in enumerate(self.listview.get_columns()): + for index, column in enumerate(self.listview.get_columns()): cname = column.get_title() if cname in state['columns']: cstate = state['columns'][cname] diff --git a/deluge/ui/gtk3/preferences.py b/deluge/ui/gtk3/preferences.py index a008a9562..301d8753f 100644 --- a/deluge/ui/gtk3/preferences.py +++ b/deluge/ui/gtk3/preferences.py @@ -295,7 +295,7 @@ class Preferences(component.Component): 'Bandwidth'""" self.window_open = True if page is not None: - for (index, string, __) in self.liststore: + for index, string, __ in self.liststore: if page == string: self.treeview.get_selection().select_path(index) break diff --git a/deluge/ui/gtk3/systemtray.py b/deluge/ui/gtk3/systemtray.py index f65fde590..5318cf2d5 100644 --- a/deluge/ui/gtk3/systemtray.py +++ b/deluge/ui/gtk3/systemtray.py @@ -144,7 +144,6 @@ class SystemTray(component.Component): def __start(self): if self.config['enable_system_tray']: - if self.config['standalone']: try: self.hide_widget_list.remove('menuitem_quitdaemon') diff --git a/deluge/ui/sessionproxy.py b/deluge/ui/sessionproxy.py index b50ba6c3d..6cb8550e6 100644 --- a/deluge/ui/sessionproxy.py +++ b/deluge/ui/sessionproxy.py @@ -190,6 +190,7 @@ class SessionProxy(component.Component): :rtype: dict """ + # Helper functions and callbacks --------------------------------------- def on_status(result, torrent_ids, keys): # Update the internal torrent status dict with the update values diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index e47a5b25a..c6128ee1d 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -447,7 +447,6 @@ class Themes(static.File): class TopLevel(resource.Resource): - __stylesheets = [ 'css/ext-all-notheme.css', 'css/ext-extensions.css', diff --git a/deluge/ui/web/web.py b/deluge/ui/web/web.py index f855bd06c..ae428c754 100644 --- a/deluge/ui/web/web.py +++ b/deluge/ui/web/web.py @@ -17,7 +17,6 @@ log = logging.getLogger(__name__) class Web(UI): - cmd_description = """Web-based user interface (http://localhost:8112)""" def __init__(self, *args, **kwargs): diff --git a/generate_pot.py b/generate_pot.py index efbdc7824..fdc7baec3 100755 --- a/generate_pot.py +++ b/generate_pot.py @@ -39,7 +39,7 @@ xgettext_cmd = [ ] to_translate = [] -for (dirpath, dirnames, filenames) in os.walk('deluge'): +for dirpath, dirnames, filenames in os.walk('deluge'): for filename in filenames: if dirpath not in EXCLUSIONS and not RE_EXC_PLUGIN_BUILD.match(dirpath): filepath = os.path.join(dirpath, filename) @@ -67,13 +67,13 @@ call(xgettext_cmd) # find javascript files js_to_translate = [] -for (dirpath, dirnames, filenames) in os.walk(WEBUI_JS_DIR): +for dirpath, dirnames, filenames in os.walk(WEBUI_JS_DIR): for filename in filenames: if os.path.splitext(filename)[1] == '.js': js_to_translate.append(os.path.join(dirpath, filename)) # find render html files -for (dirpath, dirnames, filenames) in os.walk(WEBUI_RENDER_DIR): +for dirpath, dirnames, filenames in os.walk(WEBUI_RENDER_DIR): for filename in filenames: if os.path.splitext(filename)[1] == '.html': js_to_translate.append(os.path.join(dirpath, filename))