You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2025/10/07 14:19:45 UTC
(allura) 01/02: autopep8 -i --max-line-length 9999
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 3452cbdcc1d7c832032a9a14a51b1f3169cfbe84
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Tue Oct 7 09:58:18 2025 -0400
autopep8 -i --max-line-length 9999
---
Allura/allura/command/smtp_server.py | 7 +++----
Allura/allura/config/app_cfg.py | 4 +++-
Allura/allura/controllers/site_admin.py | 2 +-
Allura/allura/lib/helpers.py | 2 ++
Allura/allura/lib/multifactor.py | 6 +++---
Allura/allura/lib/phone/nexmo.py | 2 +-
Allura/allura/lib/utils.py | 4 ++--
Allura/allura/lib/widgets/forms.py | 1 -
Allura/allura/lib/widgets/search.py | 2 +-
Allura/allura/lib/widgets/subscriptions.py | 2 +-
Allura/allura/tests/functional/test_admin.py | 2 --
Allura/allura/tests/functional/test_auth.py | 8 +++-----
Allura/allura/tests/functional/test_root.py | 5 +++--
Allura/allura/tests/functional/test_site_admin.py | 4 ++--
Allura/allura/tests/test_mail_util.py | 7 +++----
Allura/allura/tests/test_markdown.py | 2 ++
Allura/allura/tests/test_plugin.py | 1 +
Allura/allura/tests/unit/patches.py | 2 ++
AlluraTest/alluratest/smtp_debug.py | 3 +--
AlluraTest/setup.py | 2 +-
ForgeActivity/setup.py | 2 +-
ForgeBlog/setup.py | 2 +-
ForgeChat/setup.py | 2 +-
ForgeDiscussion/setup.py | 2 +-
ForgeFeedback/setup.py | 2 +-
ForgeFiles/setup.py | 2 +-
ForgeGit/setup.py | 2 +-
ForgeLink/setup.py | 2 +-
ForgeSVN/setup.py | 2 +-
ForgeShortUrl/setup.py | 2 +-
ForgeTracker/setup.py | 2 +-
ForgeUserStats/setup.py | 2 +-
ForgeWiki/setup.py | 2 +-
conftest.py | 2 ++
34 files changed, 50 insertions(+), 46 deletions(-)
diff --git a/Allura/allura/command/smtp_server.py b/Allura/allura/command/smtp_server.py
index 1ce8e2cf0..3945dbf53 100644
--- a/Allura/allura/command/smtp_server.py
+++ b/Allura/allura/command/smtp_server.py
@@ -38,7 +38,7 @@ class SMTPServerCommand(base.Command):
parser.add_option('-c', '--context', dest='context',
help=('The context of the message (path to the project'
' and/or tool'))
-
+
def command(self):
faulthandler.enable()
self.basic_setup()
@@ -49,8 +49,8 @@ def command(self):
controller.start()
while True:
time.sleep(100000)
-
-
+
+
class MailServer:
async def handle_DATA(self, server, session, envelope):
try:
@@ -73,4 +73,3 @@ async def handle_DATA(self, server, session, envelope):
return '500 Could not process your message'
return '250 OK'
-
diff --git a/Allura/allura/config/app_cfg.py b/Allura/allura/config/app_cfg.py
index b545f043c..01df3da77 100644
--- a/Allura/allura/config/app_cfg.py
+++ b/Allura/allura/config/app_cfg.py
@@ -91,7 +91,7 @@ def __init__(self, root_controller=None):
# prevent dispatcher from striping extensions like '.io' from URLs
'disable_request_extensions': True,
'validation.exceptions': [formencode.Invalid, formencode.api.Invalid,],
- 'validation.validators': {
+ 'validation.validators': {
formencode.Schema: lambda schema, params: schema.to_python(params, state=tg.request),
formencode.FancyValidator: lambda validator, params: validator.to_python(params, state=tg.request),
},
@@ -120,6 +120,7 @@ def explode_formencode_invalid(self, err):
values = {str(k): v for k, v in getattr(err, 'value', {}).items()} if hasattr(err, 'value') and isinstance(err.value, dict) else {}
return {"errors": errors, "values": values}
+
class AlluraTemplateConfig(TemplateRenderingConfigurationComponent):
def on_bind(self, configurator: ForgeConfig):
@@ -142,6 +143,7 @@ def dump_bytecode(self, bucket):
key = bucket.key
self.cache[key] = bucket.code
+
long_term_in_memory_bytecode_cache = InMemoryBytecodeCache()
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 28e678a4b..b97af6271 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -590,7 +590,7 @@ def view(self, task_id):
_id=task.context.app_config_id)
task.user = M.User.query.get(_id=task.context.user_id)
task_args = [deinstrument(a) for a in task.args]
- task_kwargs = {k: deinstrument(v) for k,v in task.kwargs.items()}
+ task_kwargs = {k: deinstrument(v) for k, v in task.kwargs.items()}
else:
task_args = []
task_kwargs = {}
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 92b3cb106..bc2f8cee2 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -723,6 +723,7 @@ def config_with_prefix(d, prefix):
return {k[plen:]: v for k, v in d.items()
if k.startswith(prefix)}
+
def needs_email_verification(user) -> dict | None:
from allura import model as M
email_addresses = M.EmailAddress.find(dict(claimed_by_user_id=user._id, confirmed=False)).all()
@@ -731,6 +732,7 @@ def needs_email_verification(user) -> dict | None:
return {'message': msg, 'status': 'warning'}
return None
+
def paging_sanitizer(limit, page, total_count=sys.maxsize, zero_based_pages=True):
"""Return limit, page - both converted to int and constrained to
valid ranges based on total_count.
diff --git a/Allura/allura/lib/multifactor.py b/Allura/allura/lib/multifactor.py
index 1f0045afc..053c670e6 100644
--- a/Allura/allura/lib/multifactor.py
+++ b/Allura/allura/lib/multifactor.py
@@ -461,7 +461,7 @@ def verify_and_remove_code(self, user, code):
class EmailCodeAuthenticationService(MongodbMultifactorCommon):
def generate_code(self, user):
code_length = 6
- code_expiration_time = 300 # seconds
+ code_expiration_time = 300 # seconds
code = ''.join(secrets.choice(string.digits) for i in range(code_length))
code_expiration_timestamp = int(time() + code_expiration_time)
@@ -473,8 +473,8 @@ def validate_code(self, user, code):
user_code_expiry = user.get_tool_data('AuthEmailCode', 'code_expiry')
if user_code:
self.enforce_rate_limit(user)
- if user_code == code and int(time()) < user_code_expiry :
+ if user_code == code and int(time()) < user_code_expiry:
# remove the AuthEmailCode tool data from the user
user.set_tool_data('AuthEmailCode', code="", code_expiry=0)
return True
- raise InvalidEmailAuthCode
\ No newline at end of file
+ raise InvalidEmailAuthCode
diff --git a/Allura/allura/lib/phone/nexmo.py b/Allura/allura/lib/phone/nexmo.py
index 39a68f162..fcaaafb79 100644
--- a/Allura/allura/lib/phone/nexmo.py
+++ b/Allura/allura/lib/phone/nexmo.py
@@ -61,7 +61,7 @@ def error(self, code=None, msg=None, number=''):
msg,
markupsafe.Markup('<br>Make sure you include the country code (see examples above)'),
markupsafe.Markup('. For US numbers, you must include <code>1-</code> before the area code.') if len(number) == 10 else '',
- )
+ )
return {'status': 'error', 'error': msg}
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 148998e5d..ed8c82b2f 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -584,8 +584,8 @@ def __init__(self, *args, **kwargs):
} | set(aslist(tg.config.get('safe_html.classes', [])))
self.valid_partial_class_prefixes = tuple(['fa-'] + aslist(tg.config.get('safe_html.class_prefixes', None)))
self.valid_id_prefixes = {
- 'h-', # see toc_slugify_with_prefix
- 'fn:', 'fnref:', # from footnotes extension
+ 'h-', # see toc_slugify_with_prefix
+ 'fn:', 'fnref:', # from footnotes extension
} | set(aslist(tg.config.get('safe_html.id_prefixes', [])))
self._prev_token_was_ok_iframe = False
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 032a7c69d..b3086f992 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -1132,7 +1132,6 @@ def validate(self, value, state=None):
return super().validate(value, state)
-
class AwardGrantForm(ForgeForm):
def __init__(self, *args, **kw):
diff --git a/Allura/allura/lib/widgets/search.py b/Allura/allura/lib/widgets/search.py
index 2950b55c9..b6474dd8e 100644
--- a/Allura/allura/lib/widgets/search.py
+++ b/Allura/allura/lib/widgets/search.py
@@ -56,7 +56,7 @@ def __init__(self, comments=True, history=True, fields={}):
autoescape=True,
loader=jinja2.PackageLoader('allura', 'templates/widgets'))
self.content = Markup(jinja2_env.get_template('search_help.html').render(dict( # noqa: S704
- comments=comments,
+ comments=comments,
history=history,
fields=fields,
)))
diff --git a/Allura/allura/lib/widgets/subscriptions.py b/Allura/allura/lib/widgets/subscriptions.py
index 64ee11e05..ddd488b8a 100644
--- a/Allura/allura/lib/widgets/subscriptions.py
+++ b/Allura/allura/lib/widgets/subscriptions.py
@@ -94,4 +94,4 @@ def resources(self):
def validate(self, value, state=None):
state = tg.request if hasattr(tg, 'request') else state
- return super().validate(value, state)
\ No newline at end of file
+ return super().validate(value, state)
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index e5fb40de3..2315ed277 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -1032,8 +1032,6 @@ def test_private_projects_perms(self):
assert len(group_perms) == 4 # read permission is being displayed
else:
assert len(group_perms) == 1
-
-
class TestExport(TestController):
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 5fd2c89c1..4d6c618b0 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -50,6 +50,7 @@
def unentity(s):
return s.replace('"', '"').replace('"', '"')
+
def login(app, username='test-user', pwd='foo', query_string=''):
extra = {'username': '*anonymous', 'REMOTE_ADDR': '127.0.0.1'}
r = app.get('/auth/' + query_string, extra_environ=extra)
@@ -258,7 +259,6 @@ def test_login_redirect(self):
status=302)
assert r.location == 'http://localhost/'
-
def test_login_overlay(self):
r = self.app.get('/auth/login_fragment/', extra_environ={'username': '*anonymous'})
f = r.forms[0]
@@ -3148,7 +3148,6 @@ def test_login_totp(self):
r = self.app.get('/auth/multifactor?return_to=/p/foo', status=302)
assert r.location == 'http://localhost/p/foo'
-
def test_login_rate_limit(self):
self._init_totp()
@@ -3480,8 +3479,7 @@ def test_untrack_user_session(self):
r = self.app.get('/auth/logout', extra_environ={'username': 'test-user'})
user = M.User.by_username('test-user')
session_ids = user.get_tool_data('web_session', 'ids')
- assert len(session_ids) == 0
-
+ assert len(session_ids) == 0
@mock.patch.dict(config, {'auth.reject_untracked_sessions': True})
def test_navigation(self):
@@ -3547,4 +3545,4 @@ def test_track_session_already_logged_in(self):
user = M.User.by_username('test-user')
session_ids = user.get_tool_data('web_session', 'ids')
- assert len(session_ids) == 1
\ No newline at end of file
+ assert len(session_ids) == 1
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index 526fb2666..3fadfa247 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -46,6 +46,7 @@
from Allura.allura.tests.functional.test_auth import login
+
def assert_globals_are_reset():
# in normal tests the globals 'stacks' are cleared
assert tg.config._object_stack() == []
@@ -322,7 +323,7 @@ def teardown_method(self, method):
ThreadLocalODMSession.flush_all()
def test_unconfirmed_message(self):
- login(self.app,username='test-user')
+ login(self.app, username='test-user')
r = self.app.get('/p/test/admin/')
assert 'Your account email address(es) are out of date or unverified' in r.text
@@ -331,6 +332,6 @@ def test_confirmed_message(self):
email = M.EmailAddress.query.get(claimed_by_user_id=u._id, email=self.unconfirmed_email)
email.confirmed = True
ThreadLocalODMSession.flush_all()
- login(self.app,username='test-admin')
+ login(self.app, username='test-admin')
r = self.app.get('/p/test/admin/')
assert 'Your account email address(es) are out of date or unverified' not in r.text
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index 926248245..ae3b358f4 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -179,13 +179,13 @@ def test_task_doc(self):
r = self.app.get('/nf/admin/task_manager/task_doc', params=dict(
task_name='allura.tests.functional.test_site_admin.test_task'))
assert json.loads(r.text)['doc'] == 'test_task doc string'
-
+
def test_project_note(self):
note_content = 'this is a test note for project'
r = self.app.post('/nf/admin/save_project_note', params=dict(shortname='test', note=note_content), status=200)
project = M.Project.query.get(shortname='test')
assert note_content == project.get_tool_data('notes', 'note')
-
+
class TestSiteAdminNotifications(TestController):
diff --git a/Allura/allura/tests/test_mail_util.py b/Allura/allura/tests/test_mail_util.py
index 867900b80..be44647a2 100644
--- a/Allura/allura/tests/test_mail_util.py
+++ b/Allura/allura/tests/test_mail_util.py
@@ -350,14 +350,13 @@ def test(self, log):
assert rcpt == (250, b'OK')
data = client.docmd("DATA")
assert data == (354, b'End data with <CR><LF>.<CR><LF>')
-
+
with SMTPClient(hostname, port, timeout=0.5) as client:
- client.sendmail('from@example.com', ['to@example.com'],"""
+ client.sendmail('from@example.com', ['to@example.com'], """
From: From Person <fr...@example.com>
To: To Person <to...@example.com>
Subject: A test
Hi Bart, this is Anne.
""")
-
+
controller.stop()
-
diff --git a/Allura/allura/tests/test_markdown.py b/Allura/allura/tests/test_markdown.py
index b92543b4e..8bd41f863 100644
--- a/Allura/allura/tests/test_markdown.py
+++ b/Allura/allura/tests/test_markdown.py
@@ -21,6 +21,7 @@
from allura.lib import markdown_extensions as mde
from tg import config as tg_config
+
class TestTracRef1:
@mock.patch('allura.lib.markdown_extensions.M.Shortlink.lookup')
@@ -82,6 +83,7 @@ def test_legit_refs(self):
assert mde.TracRef3(app).sub('source:file.py@123#L456') == '[source:file.py@123#L456](/p/project/tool/123/tree/file.py#l456)'
assert mde.TracRef3(app).sub('source:file.py#L456') == '[source:file.py#L456](/p/project/tool/HEAD/tree/file.py#l456)'
+
class TestRelativeLinkRewriter:
@mock.patch.dict(tg_config, {'nofollow_exempt_domains': '', 'domain': 'example.com'})
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index ac4fac688..c12fc6806 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -51,6 +51,7 @@ class ThemeProviderTestApp(Application):
24: 'images/testapp_24.png',
}
+
class TestProjectRegistrationProvider:
def setup_method(self, method):
diff --git a/Allura/allura/tests/unit/patches.py b/Allura/allura/tests/unit/patches.py
index ddb92ff00..d2b3551a3 100644
--- a/Allura/allura/tests/unit/patches.py
+++ b/Allura/allura/tests/unit/patches.py
@@ -63,5 +63,7 @@ def fake_request_patch(test_case):
MagicMock(
referer='.'
))
+
+
def fake_form_request_patch(test_case):
return patch('tg.request', MagicMock(referer='.'))
diff --git a/AlluraTest/alluratest/smtp_debug.py b/AlluraTest/alluratest/smtp_debug.py
index f4e1517e8..16567ec13 100644
--- a/AlluraTest/alluratest/smtp_debug.py
+++ b/AlluraTest/alluratest/smtp_debug.py
@@ -23,7 +23,6 @@
class BetterDebuggingServer:
-
async def handle_DATA(self, server, session, envelope):
try:
@@ -35,4 +34,4 @@ async def handle_DATA(self, server, session, envelope):
print(message)
except Exception as error:
return f'500 Could not process your message. Error {error}'
- return '250 OK'
\ No newline at end of file
+ return '250 OK'
diff --git a/AlluraTest/setup.py b/AlluraTest/setup.py
index fa27d0774..776f4dd1c 100644
--- a/AlluraTest/setup.py
+++ b/AlluraTest/setup.py
@@ -19,4 +19,4 @@
setup(name='AlluraTest',
version='0.1',
-)
+ )
diff --git a/ForgeActivity/setup.py b/ForgeActivity/setup.py
index 27833315a..afa1e5183 100644
--- a/ForgeActivity/setup.py
+++ b/ForgeActivity/setup.py
@@ -19,4 +19,4 @@
setup(name='ForgeActivity',
version="0.1",
-)
+ )
diff --git a/ForgeBlog/setup.py b/ForgeBlog/setup.py
index 18a212bf0..1fed8c76a 100644
--- a/ForgeBlog/setup.py
+++ b/ForgeBlog/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeBlog',
version=__version__,
-)
+ )
diff --git a/ForgeChat/setup.py b/ForgeChat/setup.py
index 119825199..0f54aac9c 100644
--- a/ForgeChat/setup.py
+++ b/ForgeChat/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeChat',
version=__version__,
-)
+ )
diff --git a/ForgeDiscussion/setup.py b/ForgeDiscussion/setup.py
index 6a6284b6c..26a6930db 100644
--- a/ForgeDiscussion/setup.py
+++ b/ForgeDiscussion/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeDiscussion',
version=__version__,
-)
+ )
diff --git a/ForgeFeedback/setup.py b/ForgeFeedback/setup.py
index 493da4917..fed23f334 100644
--- a/ForgeFeedback/setup.py
+++ b/ForgeFeedback/setup.py
@@ -23,4 +23,4 @@
setup(name='ForgeFeedback',
version=__version__,
-)
+ )
diff --git a/ForgeFiles/setup.py b/ForgeFiles/setup.py
index 0cfcadedc..8c8da0339 100755
--- a/ForgeFiles/setup.py
+++ b/ForgeFiles/setup.py
@@ -20,4 +20,4 @@
setup(name='ForgeFiles',
version='0.1.0',
-)
+ )
diff --git a/ForgeGit/setup.py b/ForgeGit/setup.py
index 70f41bc73..eb62ddfd9 100644
--- a/ForgeGit/setup.py
+++ b/ForgeGit/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeGit',
version=__version__,
-)
+ )
diff --git a/ForgeLink/setup.py b/ForgeLink/setup.py
index 99e53a9e6..5825f687b 100644
--- a/ForgeLink/setup.py
+++ b/ForgeLink/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeLink',
version=__version__,
-)
+ )
diff --git a/ForgeSVN/setup.py b/ForgeSVN/setup.py
index 4f94e9264..535d9c858 100644
--- a/ForgeSVN/setup.py
+++ b/ForgeSVN/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeSVN',
version=__version__,
-)
+ )
diff --git a/ForgeShortUrl/setup.py b/ForgeShortUrl/setup.py
index efddc6a1c..836ab34f6 100644
--- a/ForgeShortUrl/setup.py
+++ b/ForgeShortUrl/setup.py
@@ -20,4 +20,4 @@
setup(name='ForgeShortUrl',
description="",
-)
+ )
diff --git a/ForgeTracker/setup.py b/ForgeTracker/setup.py
index b9218e87a..ac3b83812 100644
--- a/ForgeTracker/setup.py
+++ b/ForgeTracker/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeTracker',
version=__version__,
-)
+ )
diff --git a/ForgeUserStats/setup.py b/ForgeUserStats/setup.py
index 7bf60d4a6..fb81858f7 100644
--- a/ForgeUserStats/setup.py
+++ b/ForgeUserStats/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeUserStats',
version=__version__,
-)
+ )
diff --git a/ForgeWiki/setup.py b/ForgeWiki/setup.py
index e19ee9d7a..425928fb7 100644
--- a/ForgeWiki/setup.py
+++ b/ForgeWiki/setup.py
@@ -22,4 +22,4 @@
setup(name='ForgeWiki',
version=__version__,
-)
+ )
diff --git a/conftest.py b/conftest.py
index fba8b5036..bbf20fcc7 100644
--- a/conftest.py
+++ b/conftest.py
@@ -17,6 +17,8 @@
import pytest
# should get rid of this once this issue is fixed https://github.com/TurboGears/tg2/issues/136
+
+
@pytest.fixture(autouse=True, scope='session')
def tg_context_patch():
from tg import (