From a27cf3d42dc9525820e56aec7f86fd2ec2a6c71b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 14:44:54 +0100 Subject: [PATCH 1/8] gitlab-ci: use black from Debian for a stable code format This avoids surprise code format CI breakage when black pushes new rules: https://gitlab.com/fdroid-bot/fdroidserver/-/jobs/3703868702 --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc046642..63c17f01 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -220,9 +220,10 @@ lint_format_safety_bandit_checks: black: - image: python:slim + image: debian:bookworm-slim + <<: *apt-template script: - - pip install black + - apt-get install black - black --check --diff --color examples/fdroid_clean_repos.py examples/fdroid_extract_repo_pubkey.py From 98769d840533de1f3294fa7b13ce5d937f745fb6 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 15:10:48 +0100 Subject: [PATCH 2/8] gitlab-ci: ignore setuptools DoS error from safety --- .safety-policy.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .safety-policy.yml diff --git a/.safety-policy.yml b/.safety-policy.yml new file mode 100644 index 00000000..7415406d --- /dev/null +++ b/.safety-policy.yml @@ -0,0 +1,7 @@ +--- + +security: + ignore-vulnerabilities: + 52495: + reason: setuptools comes from Debian + expires: '2025-01-31' From 156b3f91cc06531fcc3f2aa19910acc93e8802f0 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 15:30:35 +0100 Subject: [PATCH 3/8] fix pylint W0404: Reimport 're' (imported line 21) (reimported) --- fdroidserver/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fdroidserver/__main__.py b/fdroidserver/__main__.py index e470099c..216e00c4 100755 --- a/fdroidserver/__main__.py +++ b/fdroidserver/__main__.py @@ -159,7 +159,6 @@ def main(): output = 'git commit ' + subprocess.check_output(['git', 'rev-parse', 'HEAD'], universal_newlines=True) elif os.path.exists('setup.py'): - import re m = re.search(r'''.*[\s,\(]+version\s*=\s*["']([0-9a-z.]+)["'].*''', open('setup.py').read(), flags=re.MULTILINE) if m: From 176301d831f475c1688ad14bd10d634612d9bd9d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 15:47:51 +0100 Subject: [PATCH 4/8] fix pylint W0715: Exception arguments suggest string formatting might be intended (raising-format-tuple) --- fdroidserver/vmtools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdroidserver/vmtools.py b/fdroidserver/vmtools.py index 16f2b605..e489ce4b 100644 --- a/fdroidserver/vmtools.py +++ b/fdroidserver/vmtools.py @@ -323,7 +323,7 @@ class FDroidBuildVm: boxfile = abspath(boxfile) if not isfile(boxfile): raise FDroidBuildVmException( - 'supplied boxfile \'%s\' does not exist', boxfile + 'supplied boxfile \'%s\' does not exist' % boxfile ) self.vgrnt.box_add(boxname, abspath(boxfile), force=force) From 9d2cc1ecc57e64ec55d991666e2775f68b01762a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 15:58:15 +0100 Subject: [PATCH 5/8] fix pylint C1803: 'icons_src == {}' can be simplified to 'not icons_src' as an empty dict is falsey (use-implicit-booleaness-not-comparison) --- tests/update.TestCase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/update.TestCase b/tests/update.TestCase index 76b2739f..fe3159ce 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -1358,7 +1358,7 @@ class UpdateTest(unittest.TestCase): # pylint: disable=protected-access icons_src = fdroidserver.update._get_apk_icons_src('urzip-release.apk', None) - assert icons_src == {} + assert not icons_src def test_strip_and_copy_image(self): tmptestsdir = tempfile.mkdtemp( From 75bf953c80daf5508fcdefe1d6b21a1a83d4900b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 16:01:00 +0100 Subject: [PATCH 6/8] fix pylint: C0104: Disallowed name "bar" (disallowed-name) --- fdroidserver/deploy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fdroidserver/deploy.py b/fdroidserver/deploy.py index 13a8982b..0661bb3a 100644 --- a/fdroidserver/deploy.py +++ b/fdroidserver/deploy.py @@ -430,12 +430,12 @@ def update_servergitmirrors(servergitmirrors, repo_section): repo.index.commit("fdroidserver git-mirror") if options.verbose: - bar = progress.Bar() + progressbar = progress.Bar() class MyProgressPrinter(git.RemoteProgress): def update(self, op_code, current, maximum=None, message=None): if isinstance(maximum, float): - bar.show(current, maximum) + progressbar.show(current, maximum) progress = MyProgressPrinter() else: progress = None @@ -497,7 +497,7 @@ def update_servergitmirrors(servergitmirrors, repo_section): logging.debug(remote.url + ': ' + pushinfo.summary) if progress: - bar.done() + progressbar.done() def upload_to_android_observatory(repo_section): From b152916b492916314733ea2008d53f8e9d62d188 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 16:02:14 +0100 Subject: [PATCH 7/8] fix pylint: C1803: 'local_metadata_files != []' can be simplified to 'local_metadata_files' as an empty list is falsey (use-implicit-booleaness-not-comparison) --- fdroidserver/import_subcommand.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdroidserver/import_subcommand.py b/fdroidserver/import_subcommand.py index b9fe070a..ab0e0ed7 100644 --- a/fdroidserver/import_subcommand.py +++ b/fdroidserver/import_subcommand.py @@ -252,7 +252,7 @@ def main(): tmp_importer_dir = None local_metadata_files = common.get_local_metadata_files() - if local_metadata_files != []: + if local_metadata_files: raise FDroidException(_("This repo already has local metadata: %s") % local_metadata_files[0]) build = metadata.Build() From 497fcfc84888131c44d03c81b2cb5a92e27f708b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 2 Feb 2023 15:30:15 +0100 Subject: [PATCH 8/8] silence new pylint checks that are too much for the current state Ideally, these would be fixed. But it'll be a project. * C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) * R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return) * R1720: Unnecessary "elif" after "raise", remove the leading "el" from "elif" (no-else-raise) * R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise) * R1722: Consider using 'sys.exit' instead (consider-using-sys-exit) * R1723: Unnecessary "elif" after "break", remove the leading "el" from "elif" (no-else-break) * R1724: Unnecessary "elif" after "continue", remove the leading "el" from "elif" (no-else-continue) * R1735: Consider using '{}' instead of a call to 'dict'. (use-dict-literal) * W0133: Exception statement has no effect (pointless-exception-statement) * W0718: Catching too general exception Exception (broad-exception-caught) * W0719: Raising too general exception: Exception (broad-exception-raised) * W1510: 'subprocess.run' used without explicitly defining the value for 'check'. (subprocess-run-check) --- pyproject.toml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9e7fc078..f4f8c7b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,27 @@ confidence = ["HIGH", "INFERENCE"] # --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 = ["invalid-name", "missing-module-docstring", "missing-class-docstring", "missing-function-docstring", "no-member"] + +# TODO many of these could be fixed if someone wants to spend the time +disable = [ + "broad-exception-caught", + "broad-exception-raised", + "consider-iterating-dictionary", + "consider-using-sys-exit", + "invalid-name", + "missing-class-docstring", + "missing-function-docstring", + "missing-module-docstring", + "no-else-break", + "no-else-continue", + "no-else-raise", + "no-else-return", + "no-member", + "pointless-exception-statement", + "subprocess-run-check", + "use-dict-literal", +] + [tool.pylint.miscellaneous] # List of note tags to take in consideration, separated by a comma.