[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:
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

View File

@ -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]

View File

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

View File

@ -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)

View File

@ -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)

View File

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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

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

View File

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

View File

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

View File

@ -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 = []

View File

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

View File

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

View File

@ -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

View File

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

View File

@ -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 = []

View File

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

View File

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

View File

@ -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

View File

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

View File

@ -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)

View File

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

View File

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

View File

@ -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'

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
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

View File

@ -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:

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
class Gtk(UI):
cmd_description = """GTK-based graphical user interface"""
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:
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('')

View File

@ -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):

View File

@ -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 [

View File

@ -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]

View File

@ -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

View File

@ -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')

View File

@ -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

View File

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

View File

@ -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):

View File

@ -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))