From 0b4764504d6cf497dd87bf4a9be40eb76c4ab39c Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 14 Nov 2025 16:45:16 +0100 Subject: [PATCH] checkupdates: fix pylint invalid-name use-dict-literal no-else-return/raise --- fdroidserver/checkupdates.py | 25 ++++++++----------------- tests/test_checkupdates.py | 14 +++----------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index e7945910..ab5e43b0 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -"""Check for updates to applications.""" # # checkupdates.py - part of the FDroid server tools # Copyright (C) 2010-2015, Ciaran Gultnieks, ciaran@ciarang.com @@ -18,6 +17,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +"""Check for updates to applications.""" + import configparser import copy import logging @@ -597,7 +598,7 @@ def checkupdates_app(app: metadata.App, auto: bool, commit: bool = False) -> Non raise MetaDataException( _("Can't auto-update app with no CurrentVersionCode") ) - elif mode in ('None', 'Static'): + if mode in ('None', 'Static'): pass elif mode.startswith('Version'): pattern = mode[8:] @@ -686,8 +687,7 @@ def get_last_build_from_app(app: metadata.App) -> metadata.Build: """Get the last build entry of an app.""" if app.get('Builds'): return app['Builds'][-1] - else: - return metadata.Build() + return metadata.Build() def get_upstream_main_branch(git_repo): @@ -845,8 +845,8 @@ def push_commits(branch_name='checkupdates'): raise FDroidException( f'{remote.url} push failed: {pushinfo.flags} {pushinfo.summary}' ) - else: - logging.info(remote.url + ': ' + pushinfo.summary) + + logging.info(remote.url + ': ' + pushinfo.summary) def prune_empty_appid_branches(git_repo=None, main_branch='main'): @@ -879,19 +879,10 @@ def status_update_json(processed: list, failed: dict) -> None: common.write_status_json(output) -config = None start_timestamp = time.gmtime() def main(): - """Check for updates for one or more apps. - - The behaviour of this function is influenced by the configuration file as - well as command line parameters. - """ - global config - - # Parse command line... parser = ArgumentParser() common.setup_global_opts(parser) parser.add_argument("appid", nargs='*', help=_("application ID of file to operate on")) @@ -909,7 +900,7 @@ def main(): options = common.parse_args(parser) metadata.warnings_action = options.W - config = common.read_config() + common.read_config() # only needed for functions from fdroidserver if not options.allow_dirty: status = subprocess.check_output(['git', 'status', '--porcelain']) @@ -924,7 +915,7 @@ def main(): apps = common.read_app_args(options.appid) processed = [] - failed = dict() + failed = {} exit_code = 0 for appid, app in apps.items(): diff --git a/tests/test_checkupdates.py b/tests/test_checkupdates.py index 107caf29..9914e951 100755 --- a/tests/test_checkupdates.py +++ b/tests/test_checkupdates.py @@ -30,8 +30,6 @@ class CheckupdatesTest(unittest.TestCase): self.testdir.cleanup() def test_autoupdatemode_no_suffix(self): - fdroidserver.checkupdates.config = {} - app = fdroidserver.metadata.App() app.id = 'loop.starts.shooting' app.metadatapath = 'metadata/' + app.id + '.yml' @@ -69,8 +67,6 @@ class CheckupdatesTest(unittest.TestCase): self.assertEqual(build.commit, '1.1.9') def test_autoupdatemode_suffix(self): - fdroidserver.checkupdates.config = {} - app = fdroidserver.metadata.App() app.id = 'loop.starts.shooting' app.metadatapath = 'metadata/' + app.id + '.yml' @@ -96,8 +92,6 @@ class CheckupdatesTest(unittest.TestCase): self.assertEqual(build.commit, 'v1.1.9_10109') def test_autoupdate_multi_variants(self): - fdroidserver.checkupdates.config = {} - app = fdroidserver.metadata.App() app.id = 'loop.starts.shooting' app.metadatapath = 'metadata/' + app.id + '.yml' @@ -144,8 +138,6 @@ class CheckupdatesTest(unittest.TestCase): self.assertEqual(app.CurrentVersionCode, 101093) def test_checkupdates_app_http(self): - fdroidserver.checkupdates.config = {} - app = fdroidserver.metadata.App() app.id = 'loop.starts.shooting' app.metadatapath = 'metadata/' + app.id + '.yml' @@ -170,8 +162,6 @@ class CheckupdatesTest(unittest.TestCase): wrmock.assert_called_with(app.metadatapath, app) def test_checkupdates_app_tags(self): - fdroidserver.checkupdates.config = {} - app = fdroidserver.metadata.App() app.id = 'loop.starts.shooting' app.metadatapath = 'metadata/' + app.id + '.yml' @@ -414,6 +404,8 @@ class CheckupdatesTest(unittest.TestCase): def test_push_commits_verbose(self): class Options: + """Fake the argparse options.""" + verbose = True fdroidserver.checkupdates.options = Options @@ -465,7 +457,7 @@ class CheckupdatesTest(unittest.TestCase): self.assertNotEqual(return_code, 0) raise fdroidserver.exception.FDroidException('sys.exit() ran') - def _read_metadata(a=None, b=None): + def _read_metadata(_a=None, _b=None): raise StopIteration('read_metadata() ran, test is successful') appid = 'com.example'