From 468ed4636e05684ef43a3a970f99a540411d65d1 Mon Sep 17 00:00:00 2001 From: Dave Brondsema Date: Wed, 20 Mar 2024 17:10:45 -0400 Subject: [PATCH] [#8539] add some pylint checks --- Allura/allura/command/base.py | 2 +- Allura/allura/lib/helpers.py | 2 +- Allura/allura/lib/patches.py | 2 +- Allura/allura/tests/functional/test_discuss.py | 3 +-- Allura/allura/websetup/bootstrap.py | 2 +- ruff.toml | 4 ++++ scripts/ApacheAccessHandler.py | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Allura/allura/command/base.py b/Allura/allura/command/base.py index 65b7c758e6..de09018c9c 100644 --- a/Allura/allura/command/base.py +++ b/Allura/allura/command/base.py @@ -87,7 +87,7 @@ def config(self): return tg.config def basic_setup(self): - global log, M + global log, M # noqa: PLW0603 if self.args[0]: # Probably being called from the command line - load the config # file diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py index 5f5c41bdf4..26d031446d 100644 --- a/Allura/allura/lib/helpers.py +++ b/Allura/allura/lib/helpers.py @@ -32,7 +32,7 @@ import logging import string import random -import pickle as pickle +import pickle from hashlib import sha1 from datetime import datetime, timedelta from collections import defaultdict, OrderedDict diff --git a/Allura/allura/lib/patches.py b/Allura/allura/lib/patches.py index 7c6e416eb4..964624d0bc 100644 --- a/Allura/allura/lib/patches.py +++ b/Allura/allura/lib/patches.py @@ -29,7 +29,7 @@ _patched = False def apply(): - global _patched + global _patched # noqa: PLW0603 if _patched: return _patched = True diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py index f87f4352d5..100f9b2762 100644 --- a/Allura/allura/tests/functional/test_discuss.py +++ b/Allura/allura/tests/functional/test_discuss.py @@ -426,8 +426,7 @@ def attach_link(self): if 'attachment' in alink['href']: alink = str(alink['href']) return alink - else: - assert False, 'attachment link not found' + assert False, 'attachment link not found' def test_attach(self): r = self.app.post(self.post_link + 'attach', diff --git a/Allura/allura/websetup/bootstrap.py b/Allura/allura/websetup/bootstrap.py index eadd141e92..21cfa67816 100644 --- a/Allura/allura/websetup/bootstrap.py +++ b/Allura/allura/websetup/bootstrap.py @@ -56,7 +56,7 @@ def bootstrap(command, conf, vars): REGISTRY.register(ew.widget_context, ew.core.WidgetContext('http', ew.ResourceManager())) - create_test_data = asbool(os.getenv('ALLURA_TEST_DATA', True)) + create_test_data = asbool(os.getenv('ALLURA_TEST_DATA', 'true')) # if this is a test_run, skip user project creation to save time make_user_projects = not test_run diff --git a/ruff.toml b/ruff.toml index 7da9443395..4337590c59 100644 --- a/ruff.toml +++ b/ruff.toml @@ -33,6 +33,9 @@ lint.select = [ "G010", # logging.warn "T10", # debugger breakpoints "T20", # print() + "PLC", + "PLE", + "PLW", "FA", # future annotations (to ensure compatibility with `target-version`) ] @@ -57,6 +60,7 @@ lint.ignore = [ 'S324', # md5 & sha1 'S603', # subprocess 'S607', # partial path + 'PLW2901', # loop var overwritten ] [lint.per-file-ignores] diff --git a/scripts/ApacheAccessHandler.py b/scripts/ApacheAccessHandler.py index 217e4ecf61..fc10499a12 100644 --- a/scripts/ApacheAccessHandler.py +++ b/scripts/ApacheAccessHandler.py @@ -52,7 +52,7 @@ def load_requests_lib(req): exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), {'__file__': activate_this}) # noqa: S102 except Exception as e: log(req, "Couldn't activate venv via {}: {}".format(activate_this, repr(e))) - global requests + global requests # noqa: PLW0603 import requests as requests_lib requests = requests_lib