[Lint] Update pre-commit apps to latest versions

Also update github CI action versions
This commit is contained in:
Calum Lind 2023-02-24 14:56:23 +00:00
parent 45c9f3b90a
commit 930cf87103
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
40 changed files with 21 additions and 51 deletions

View File

@ -11,7 +11,7 @@ jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-python@v2 - uses: actions/setup-python@v4
- name: Run pre-commit linting - name: Run pre-commit linting
uses: pre-commit/action@v2.0.2 uses: pre-commit/action@v3.0.0

View File

@ -7,12 +7,12 @@ exclude: >
)$ )$
repos: repos:
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.3.0 rev: 23.1.0
hooks: hooks:
- id: black - id: black
name: Fmt Black name: Fmt Black
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1 rev: v2.7.1
hooks: hooks:
- id: prettier - id: prettier
name: Fmt Prettier name: Fmt Prettier
@ -24,14 +24,14 @@ repos:
- id: isort - id: isort
name: Fmt isort name: Fmt isort
- repo: https://github.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 4.0.1 rev: 6.0.0
hooks: hooks:
- id: flake8 - id: flake8
name: Chk Flake8 name: Chk Flake8
additional_dependencies: additional_dependencies:
- pep8-naming==0.12.1 - pep8-naming==0.12.1
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 rev: v4.4.0
hooks: hooks:
- id: double-quote-string-fixer - id: double-quote-string-fixer
name: Fix Double-quotes name: Fix Double-quotes
@ -44,7 +44,7 @@ repos:
- id: trailing-whitespace - id: trailing-whitespace
name: Fix Trailing whitespace name: Fix Trailing whitespace
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.31.0 rev: v3.3.1
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py36-plus] args: [--py36-plus]

View File

@ -85,7 +85,6 @@ def bdecode(x):
class Bencached: class Bencached:
__slots__ = ['bencoded'] __slots__ = ['bencoded']
def __init__(self, s): def __init__(self, s):

View File

@ -875,7 +875,7 @@ def get_path_size(path):
return os.path.getsize(path) return os.path.getsize(path)
dir_size = 0 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: for _file in files:
filename = os.path.join(p, _file) filename = os.path.join(p, _file)
dir_size += os.path.getsize(filename) dir_size += os.path.getsize(filename)

View File

@ -90,7 +90,7 @@ class AlertManager(component.Component):
:param handler: func, the handler function to deregister :param handler: func, the handler function to deregister
""" """
# Iterate through all handlers and remove 'handler' where found # 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: if handler in value:
# Handler is in this alert type list # Handler is in this alert type list
value.remove(handler) value.remove(handler)

View File

@ -1000,7 +1000,6 @@ class Core(component.Component):
trackers, trackers,
add_to_session, add_to_session,
): ):
log.debug('creating torrent..') log.debug('creating torrent..')
threading.Thread( threading.Thread(
target=self._create_torrent_thread, target=self._create_torrent_thread,

View File

@ -166,7 +166,8 @@ def deprecated(func):
class CoroutineDeferred(defer.Deferred): class CoroutineDeferred(defer.Deferred):
"""Wraps a coroutine in a 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): def __init__(self, coro: Coroutine):
# Delay this import to make sure a reactor was installed first # Delay this import to make sure a reactor was installed first

View File

@ -51,7 +51,7 @@ def get_languages():
name = LANGUAGES[lang_code] name = LANGUAGES[lang_code]
lang.append([lang_code, _(name)]) lang.append([lang_code, _(name)])
lang = sorted(lang, key=lambda l: l[1]) lang = sorted(lang, key=lambda k: k[1])
return lang return lang

View File

@ -117,7 +117,7 @@ class TorrentMetadata:
files = [] files = []
padding_count = 0 padding_count = 0
# Collect a list of file paths and add padding files if necessary # 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): for index, filename in enumerate(filenames):
size = get_path_size( size = get_path_size(
os.path.join(self.data_path, dirpath, filename) os.path.join(self.data_path, dirpath, filename)

View File

@ -80,7 +80,6 @@ def check_input(cond, message):
class Core(CorePluginBase): class Core(CorePluginBase):
def enable(self): def enable(self):
# reduce typing, assigning some values to self... # reduce typing, assigning some values to self...
self.config = deluge.configmanager.ConfigManager('autoadd.conf', DEFAULT_PREFS) self.config = deluge.configmanager.ConfigManager('autoadd.conf', DEFAULT_PREFS)
self.config.run_converter((0, 1), 2, self.__migrate_config_1_to_2) self.config.run_converter((0, 1), 2, self.__migrate_config_1_to_2)

View File

@ -23,6 +23,5 @@ FORMAT_LIST = [
class WebUI(WebPluginBase): class WebUI(WebPluginBase):
scripts = [get_resource('blocklist.js')] scripts = [get_resource('blocklist.js')]
debug_scripts = scripts debug_scripts = scripts

View File

@ -16,6 +16,5 @@ log = logging.getLogger(__name__)
class WebUI(WebPluginBase): class WebUI(WebPluginBase):
scripts = [get_resource('execute.js')] scripts = [get_resource('execute.js')]
debug_scripts = scripts debug_scripts = scripts

View File

@ -20,6 +20,5 @@ log = logging.getLogger(__name__)
class WebUI(WebPluginBase): class WebUI(WebPluginBase):
scripts = [get_resource('extractor.js')] scripts = [get_resource('extractor.js')]
debug_scripts = scripts debug_scripts = scripts

View File

@ -31,7 +31,6 @@ NO_LABEL = 'No Label'
# menu # menu
class LabelSidebarMenu: class LabelSidebarMenu:
def __init__(self): def __init__(self):
self.treeview = component.get('FilterTreeView') self.treeview = component.get('FilterTreeView')
self.menu = self.treeview.menu self.menu = self.treeview.menu
self.items = [] self.items = []

View File

@ -21,7 +21,6 @@ log = logging.getLogger(__name__)
class WebUI(WebPluginBase): class WebUI(WebPluginBase):
scripts = [get_resource('notifications.js')] scripts = [get_resource('notifications.js')]
debug_scripts = scripts debug_scripts = scripts

View File

@ -19,6 +19,5 @@ log = logging.getLogger(__name__)
class WebUI(WebPluginBase): class WebUI(WebPluginBase):
scripts = [get_resource('scheduler.js')] scripts = [get_resource('scheduler.js')]
debug_scripts = scripts debug_scripts = scripts

View File

@ -20,7 +20,6 @@ log = logging.getLogger(__name__)
class WebUI(WebPluginBase): class WebUI(WebPluginBase):
scripts = [get_resource('stats.js')] scripts = [get_resource('stats.js')]
# The enable and disable methods are not scrictly required on the WebUI # The enable and disable methods are not scrictly required on the WebUI

View File

@ -21,7 +21,6 @@ log = logging.getLogger(__name__)
class WebUI(WebPluginBase): class WebUI(WebPluginBase):
scripts = [get_resource('toggle.js')] scripts = [get_resource('toggle.js')]
def enable(self): def enable(self):

View File

@ -14,7 +14,6 @@ log = logging.getLogger(__name__)
class PluginBase(component.Component): class PluginBase(component.Component):
update_interval = 1 update_interval = 1
def __init__(self, name): def __init__(self, name):
@ -57,7 +56,6 @@ class Gtk3PluginBase(PluginBase):
class WebPluginBase(PluginBase): class WebPluginBase(PluginBase):
scripts = [] scripts = []
debug_scripts = [] debug_scripts = []

View File

@ -49,7 +49,6 @@ options = parser.parse_args()
def create_plugin(): def create_plugin():
if not options.url: if not options.url:
options.url = '' options.url = ''

View File

@ -19,7 +19,6 @@ setup_logger('none')
class DelugeRPCProtocolTester(DelugeRPCProtocol): class DelugeRPCProtocolTester(DelugeRPCProtocol):
messages = [] messages = []
def transfer_message(self, data): def transfer_message(self, data):

View File

@ -46,7 +46,6 @@ class SecurityBaseTestCase:
) )
def on_result(results): def on_result(results):
if test == '-e': if test == '-e':
results = results[0].split(b'\n')[7:-6] results = results[0].split(b'\n')[7:-6]
assert len(results) > 3 assert len(results) > 3

View File

@ -35,7 +35,6 @@ setup_translation()
@pytest.mark.gtkui @pytest.mark.gtkui
class TestTorrentview(BaseTestCase): class TestTorrentview(BaseTestCase):
default_column_index = [ default_column_index = [
'filter', 'filter',
'torrent_id', 'torrent_id',

View File

@ -25,7 +25,6 @@ common.disable_new_release_check()
class TestWebServer(WebServerTestBase, WebServerMockBase): class TestWebServer(WebServerTestBase, WebServerMockBase):
@pytest_twisted.inlineCallbacks @pytest_twisted.inlineCallbacks
def test_get_torrent_info(self): def test_get_torrent_info(self):
agent = Agent(reactor) agent = Agent(reactor)
self.mock_authentication_ignore(self.deluge_web.auth) self.mock_authentication_ignore(self.deluge_web.auth)

View File

@ -142,7 +142,6 @@ class Commander:
class BaseCommand: class BaseCommand:
usage = None usage = None
interactive_only = False interactive_only = False
aliases = [] aliases = []

View File

@ -61,7 +61,6 @@ class LogStream:
class Console(UI): class Console(UI):
cmd_description = """Console or command-line user interface""" cmd_description = """Console or command-line user interface"""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

View File

@ -181,7 +181,6 @@ class TorrentDetail(BaseMode, PopupsHandler):
self.refresh() self.refresh()
def set_state(self, state): def set_state(self, state):
if state.get('files'): if state.get('files'):
self.full_names = {x['index']: x['path'] for x in state['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) ).addCallback(self.set_state)
def draw_files(self, files, depth, off, idx): def draw_files(self, files, depth, off, idx):
color_selected = 'blue' color_selected = 'blue'
color_partially_selected = 'magenta' color_partially_selected = 'magenta'
color_highlighted = 'white' color_highlighted = 'white'

View File

@ -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 # 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): def torrent_actions_popup(mode, torrent_ids, details=False, action=None, close_cb=None):
if action is not None: if action is not None:
torrent_action(action, mode=mode, torrent_ids=torrent_ids) torrent_action(action, mode=mode, torrent_ids=torrent_ids)
return return

View File

@ -130,7 +130,6 @@ class Popup(BaseWindow, InputKeyHandler):
BaseWindow.refresh(self) BaseWindow.refresh(self)
def calculate_size(self): def calculate_size(self):
if isinstance(self.height_req, float) and 0.0 < self.height_req <= 1.0: if isinstance(self.height_req, float) and 0.0 < self.height_req <= 1.0:
height = int((self.parent.rows - 2) * self.height_req) height = int((self.parent.rows - 2) * self.height_req)
else: else:

View File

@ -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 # Keep this class in __init__.py to avoid the console having to import everything in gtkui.py
class Gtk(UI): class Gtk(UI):
cmd_description = """GTK-based graphical user interface""" cmd_description = """GTK-based graphical user interface"""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

View File

@ -245,7 +245,7 @@ class FilesTab(Tab):
if state['sort_id'] is not None and state['sort_order'] is not None: 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']) 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() cname = column.get_title()
if cname in state['columns']: if cname in state['columns']:
cstate = state['columns'][cname] cstate = state['columns'][cname]
@ -759,7 +759,6 @@ class FilesTab(Tab):
fd['path'] = fd['path'].replace(old_folder, new_folder, 1) fd['path'] = fd['path'].replace(old_folder, new_folder, 1)
if torrent_id == self.torrent_id: if torrent_id == self.torrent_id:
old_split = old_folder.split('/') old_split = old_folder.split('/')
try: try:
old_split.remove('') old_split.remove('')

View File

@ -44,7 +44,6 @@ log = logging.getLogger(__name__)
class _GtkBuilderSignalsHolder: class _GtkBuilderSignalsHolder:
def connect_signals(self, mapping_or_class): def connect_signals(self, mapping_or_class):
if isinstance(mapping_or_class, dict): if isinstance(mapping_or_class, dict):
for name, handler in mapping_or_class.items(): for name, handler in mapping_or_class.items():
if hasattr(self, name): if hasattr(self, name):

View File

@ -62,7 +62,6 @@ def path_without_trailing_path_sep(path):
class ValueList: class ValueList:
paths_without_trailing_path_sep = False paths_without_trailing_path_sep = False
def get_values_count(self): def get_values_count(self):
@ -1097,7 +1096,6 @@ class PathAutoCompleter:
class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject): class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject):
__gsignals__ = { __gsignals__ = {
signal: (SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,)) signal: (SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,))
for signal in [ for signal in [

View File

@ -186,7 +186,7 @@ class PeersTab(Tab):
if state['sort_id'] and state['sort_order'] is not None: if state['sort_id'] and state['sort_order'] is not None:
self.liststore.set_sort_column_id(state['sort_id'], state['sort_order']) 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() cname = column.get_title()
if cname in state['columns']: if cname in state['columns']:
cstate = state['columns'][cname] cstate = state['columns'][cname]

View File

@ -295,7 +295,7 @@ class Preferences(component.Component):
'Bandwidth'""" 'Bandwidth'"""
self.window_open = True self.window_open = True
if page is not None: if page is not None:
for (index, string, __) in self.liststore: for index, string, __ in self.liststore:
if page == string: if page == string:
self.treeview.get_selection().select_path(index) self.treeview.get_selection().select_path(index)
break break

View File

@ -144,7 +144,6 @@ class SystemTray(component.Component):
def __start(self): def __start(self):
if self.config['enable_system_tray']: if self.config['enable_system_tray']:
if self.config['standalone']: if self.config['standalone']:
try: try:
self.hide_widget_list.remove('menuitem_quitdaemon') self.hide_widget_list.remove('menuitem_quitdaemon')

View File

@ -190,6 +190,7 @@ class SessionProxy(component.Component):
:rtype: dict :rtype: dict
""" """
# Helper functions and callbacks --------------------------------------- # Helper functions and callbacks ---------------------------------------
def on_status(result, torrent_ids, keys): def on_status(result, torrent_ids, keys):
# Update the internal torrent status dict with the update values # Update the internal torrent status dict with the update values

View File

@ -447,7 +447,6 @@ class Themes(static.File):
class TopLevel(resource.Resource): class TopLevel(resource.Resource):
__stylesheets = [ __stylesheets = [
'css/ext-all-notheme.css', 'css/ext-all-notheme.css',
'css/ext-extensions.css', 'css/ext-extensions.css',

View File

@ -17,7 +17,6 @@ log = logging.getLogger(__name__)
class Web(UI): class Web(UI):
cmd_description = """Web-based user interface (http://localhost:8112)""" cmd_description = """Web-based user interface (http://localhost:8112)"""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

View File

@ -39,7 +39,7 @@ xgettext_cmd = [
] ]
to_translate = [] to_translate = []
for (dirpath, dirnames, filenames) in os.walk('deluge'): for dirpath, dirnames, filenames in os.walk('deluge'):
for filename in filenames: for filename in filenames:
if dirpath not in EXCLUSIONS and not RE_EXC_PLUGIN_BUILD.match(dirpath): if dirpath not in EXCLUSIONS and not RE_EXC_PLUGIN_BUILD.match(dirpath):
filepath = os.path.join(dirpath, filename) filepath = os.path.join(dirpath, filename)
@ -67,13 +67,13 @@ call(xgettext_cmd)
# find javascript files # find javascript files
js_to_translate = [] 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: for filename in filenames:
if os.path.splitext(filename)[1] == '.js': if os.path.splitext(filename)[1] == '.js':
js_to_translate.append(os.path.join(dirpath, filename)) js_to_translate.append(os.path.join(dirpath, filename))
# find render html files # 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: for filename in filenames:
if os.path.splitext(filename)[1] == '.html': if os.path.splitext(filename)[1] == '.html':
js_to_translate.append(os.path.join(dirpath, filename)) js_to_translate.append(os.path.join(dirpath, filename))