Skip to content

Commit

Permalink
run: find Allura* Forge* fuse/ scripts/ -name '*.py' | xargs pyupgrad…
Browse files Browse the repository at this point in the history
…e --py39-plus --keep-mock && git co scripts/ApacheAccessHandler.py
  • Loading branch information
brondsem committed Oct 11, 2024
1 parent c5eb829 commit da1cbe5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Allura/allura/lib/markdown_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)'''


def clear_markdown_registry(reg: markdown.util.Registry, keep: List[str] = []):
def clear_markdown_registry(reg: markdown.util.Registry, keep: list[str] = []):
keep_items = {}
for name in keep:
keep_items[name] = reg[name]
Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@ class AdminExtension:

project_admin_controllers = {}

def update_project_sidebar_menu(self, sidebar_links: list['SitemapEntry']) -> list['SitemapEntry']:
def update_project_sidebar_menu(self, sidebar_links: list[SitemapEntry]) -> list[SitemapEntry]:
"""
Implement this function to modify the project sidebar.
Check `c.project` if you want to limit when this displays
Expand Down
20 changes: 10 additions & 10 deletions Allura/allura/lib/widgets/form_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ def resources(self):
k: getattr(self, k)
for k in self.js_params}
yield onready('''
$(document).on('clone', function () {
$('.%s').%s(%s); });
$(document).on('clone', function () {{
$('.{}').{}({}); }});
$(document).trigger('clone');
''' % (self.container_cls, self.js_widget_name, json.dumps(opts)))
'''.format(self.container_cls, self.js_widget_name, json.dumps(opts)))


class SortableRepeatedMixin(JQueryMixin):
Expand Down Expand Up @@ -503,16 +503,16 @@ class Lightbox(ew_core.Widget):
def resources(self):
yield ew.JSLink('js/jquery.lightbox_me.js')
yield onready('''
var $lightbox = $('#lightbox_%s');
$('body').on('click', '%s', function(e) {
var $lightbox = $('#lightbox_{}');
$('body').on('click', '{}', function(e) {{
e.preventDefault();
$lightbox.lightbox_me(%s);
});
$lightbox.on('click', '.close', function(e) {
$lightbox.lightbox_me({});
}});
$lightbox.on('click', '.close', function(e) {{
e.preventDefault();
$lightbox.trigger('close');
});
''' % (self.name, self.trigger, self.options))
}});
'''.format(self.name, self.trigger, self.options))


class DisplayOnlyField(ew.HiddenField):
Expand Down
22 changes: 11 additions & 11 deletions Allura/allura/model/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def before_save(data):
if c.project and not skip_last_updated:
c.project.last_updated = datetime.utcnow()

query: 'Query[Artifact]'
query: Query[Artifact]

type_s = 'Generic Artifact'

Expand Down Expand Up @@ -548,7 +548,7 @@ class __mongometa__:
'author.id',
]

query: 'Query[Snapshot]'
query: Query[Snapshot]

_id = FieldProperty(S.ObjectId)
artifact_id = FieldProperty(S.ObjectId)
Expand Down Expand Up @@ -623,7 +623,7 @@ class __mongometa__:
name = 'versioned_artifact'
history_class = Snapshot

query: 'Query[VersionedArtifact]'
query: Query[VersionedArtifact]

version = FieldProperty(S.Int, if_missing=0)

Expand Down Expand Up @@ -743,7 +743,7 @@ class __mongometa__:
session = artifact_orm_session
name = 'message'

query: 'Query[Message]'
query: Query[Message]

type_s = 'Generic Message'

Expand Down Expand Up @@ -794,7 +794,7 @@ class __mongometa__:
session = main_orm_session
name = 'award_file'

query: 'Query[AwardFile]'
query: Query[AwardFile]

award_id = FieldProperty(S.ObjectId)

Expand All @@ -806,7 +806,7 @@ class __mongometa__:
name = 'award'
indexes = ['short']

query: 'Query[Award]'
query: Query[Award]

type_s = 'Generic Award'

Expand Down Expand Up @@ -852,7 +852,7 @@ class __mongometa__:
name = 'grant'
indexes = ['short']

query: 'Query[AwardGrant]'
query: Query[AwardGrant]

type_s = 'Generic Award Grant'

Expand Down Expand Up @@ -941,7 +941,7 @@ class __mongometa__:
('pubdate', pymongo.DESCENDING)),
]

query: 'Query[Feed]'
query: Query[Feed]

_id = FieldProperty(S.ObjectId)
ref_id: str = ForeignIdProperty('ArtifactReference')
Expand Down Expand Up @@ -1068,7 +1068,7 @@ class __mongometa__:
session = main_orm_session
name = 'vote'

query: 'Query[VotableArtifact]'
query: Query[VotableArtifact]

votes = FieldProperty(int, if_missing=0)
votes_up = FieldProperty(int, if_missing=0)
Expand Down Expand Up @@ -1198,7 +1198,7 @@ class __mongometa__:
session = artifact_orm_session
name = 'moved_artifact'

query: 'Query[MovedArtifact]'
query: Query[MovedArtifact]

_id = FieldProperty(S.ObjectId)
app_config_id = ForeignIdProperty(
Expand All @@ -1216,7 +1216,7 @@ class __mongometa__:
('user_id', 'result'),
]

query: 'Query[SpamCheckResult]'
query: Query[SpamCheckResult]

_id = FieldProperty(S.ObjectId)
ref_id: str = ForeignIdProperty('ArtifactReference')
Expand Down
6 changes: 3 additions & 3 deletions Allura/allura/model/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ def send_verification_link(self):
self.set_nonce_hash()
log.info('Sending verification link to %s', self.email)
text = '''
To verify the email address %s belongs to the user %s,
To verify the email address {} belongs to the user {},
please visit the following URL:
%s
''' % (self.email,
{}
'''.format(self.email,
self.claimed_by_user(include_pending=True).username,
h.absurl(f'/auth/verify_addr?a={h.urlquote(self.nonce)}'),
)
Expand Down
10 changes: 5 additions & 5 deletions Allura/allura/model/discuss.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Discussion(Artifact, ActivityObject):
class __mongometa__:
name = 'discussion'

query: 'Query[Discussion]'
query: Query[Discussion]

type_s = 'Discussion'

Expand Down Expand Up @@ -168,7 +168,7 @@ class __mongometa__:
('discussion_id',),
]

query: 'Query[Thread]'
query: Query[Thread]

type_s = 'Thread'

Expand Down Expand Up @@ -492,7 +492,7 @@ class PostHistory(Snapshot):
class __mongometa__:
name = 'post_history'

query: 'Query[PostHistory]'
query: Query[PostHistory]

artifact_id = ForeignIdProperty('Post')

Expand Down Expand Up @@ -540,7 +540,7 @@ class __mongometa__:
('deleted', 'discussion_id', 'thread_id', 'full_slug'),
]

query: 'Query[Post]'
query: Query[Post]

type_s = 'Post'

Expand Down Expand Up @@ -862,7 +862,7 @@ class __mongometa__:
polymorphic_identity = 'DiscussionAttachment'
indexes = ['filename', 'discussion_id', 'thread_id', 'post_id']

query: 'Query[DiscussionAttachment]'
query: Query[DiscussionAttachment]

discussion_id = FieldProperty(schema.ObjectId)
thread_id = FieldProperty(str)
Expand Down
2 changes: 1 addition & 1 deletion Allura/allura/model/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ def parent_security_context(self):
'''ACL processing should terminate at the AppConfig'''
return None

def load(self) -> typing.Type[Application]:
def load(self) -> type[Application]:
"""
:returns: the related :class:`Application <allura.app.Application>` class
"""
Expand Down
4 changes: 2 additions & 2 deletions Allura/allura/tests/functional/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,9 +1725,9 @@ def test_password_reset(self, gen_message_id, sendsimplemail):
# confirm email sent
text = '''Your username is test-admin
To update your password on %s, please visit the following URL:
To update your password on {}, please visit the following URL:
%s/auth/forgotten_password/%s''' % (config['site_name'], config['base_url'], hash)
{}/auth/forgotten_password/{}'''.format(config['site_name'], config['base_url'], hash)
sendsimplemail.post.assert_called_once_with(
sender='noreply@localhost',
toaddr=email.email,
Expand Down
4 changes: 2 additions & 2 deletions Allura/allura/tests/functional/test_site_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,9 @@ def test_send_password_reset_link(self, gen_message_id, sendmail):
hash = user.get_tool_data('AuthPasswordReset', 'hash')
text = '''Your username is test-user
To update your password on %s, please visit the following URL:
To update your password on {}, please visit the following URL:
%s/auth/forgotten_password/%s''' % (config['site_name'], config['base_url'], hash)
{}/auth/forgotten_password/{}'''.format(config['site_name'], config['base_url'], hash)
sendmail.post.assert_called_once_with(
sender='noreply@localhost',
toaddr='[email protected]',
Expand Down

0 comments on commit da1cbe5

Please sign in to comment.