# HG changeset patch # User RhodeCode Admin # Date 2023-07-18 12:45:20 # Node ID aa627a5fc8f67718feda8851c5306e13294cd153 # Parent 71df309f91b565ed72548bc8ad9ded400c95c31d modernize: updates for python3 diff --git a/rhodecode/__init__.py b/rhodecode/__init__.py --- a/rhodecode/__init__.py +++ b/rhodecode/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -22,7 +21,7 @@ import datetime import collections now = datetime.datetime.now() -now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + "{:03d}".format(int(now.microsecond/1000)) +now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + f"{int(now.microsecond/1000):03d}" print(f'{now} Starting RhodeCode imports...') diff --git a/rhodecode/api/__init__.py b/rhodecode/api/__init__.py --- a/rhodecode/api/__init__.py +++ b/rhodecode/api/__init__.py @@ -355,7 +355,7 @@ def setup_request(request): json_body = ext_json.json.loads(raw_body) except ValueError as e: # catch JSON errors Here - raise JSONRPCError("JSON parse error ERR:{} RAW:{!r}".format(e, raw_body)) + raise JSONRPCError(f"JSON parse error ERR:{e} RAW:{raw_body!r}") request.rpc_id = json_body.get('id') request.rpc_method = json_body.get('method') diff --git a/rhodecode/api/tests/__init__.py b/rhodecode/api/tests/__init__.py --- a/rhodecode/api/tests/__init__.py +++ b/rhodecode/api/tests/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/api/tests/conftest.py b/rhodecode/api/tests/conftest.py --- a/rhodecode/api/tests/conftest.py +++ b/rhodecode/api/tests/conftest.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -44,7 +43,7 @@ def testuser_api(request, baseapp): # create TOKEN for user, if he doesn't have one if not cls.test_user.api_key: AuthTokenModel().create( - user=cls.test_user, description=u'TEST_USER_TOKEN') + user=cls.test_user, description='TEST_USER_TOKEN') Session().commit() cls.TEST_USER_LOGIN = cls.test_user.username diff --git a/rhodecode/api/tests/test_add_user_to_user_group.py b/rhodecode/api/tests/test_add_user_to_user_group.py --- a/rhodecode/api/tests/test_add_user_to_user_group.py +++ b/rhodecode/api/tests/test_add_user_to_user_group.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/api/tests/test_api.py b/rhodecode/api/tests/test_api.py --- a/rhodecode/api/tests/test_api.py +++ b/rhodecode/api/tests/test_api.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -31,7 +30,7 @@ class TestApi(object): def test_Optional_object(self): option1 = Optional(None) - assert '' % (None,) == repr(option1) + assert ''.format(None) == repr(option1) assert option1() is None assert 1 == Optional.extract(Optional(1)) diff --git a/rhodecode/api/tests/test_cleanup_sessions.py b/rhodecode/api/tests/test_cleanup_sessions.py --- a/rhodecode/api/tests/test_cleanup_sessions.py +++ b/rhodecode/api/tests/test_cleanup_sessions.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2017-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/api/tests/test_close_pull_request.py b/rhodecode/api/tests/test_close_pull_request.py --- a/rhodecode/api/tests/test_close_pull_request.py +++ b/rhodecode/api/tests/test_close_pull_request.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/api/tests/test_comment_commit.py b/rhodecode/api/tests/test_comment_commit.py --- a/rhodecode/api/tests/test_comment_commit.py +++ b/rhodecode/api/tests/test_comment_commit.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/api/views/gist_api.py b/rhodecode/api/views/gist_api.py --- a/rhodecode/api/views/gist_api.py +++ b/rhodecode/api/views/gist_api.py @@ -49,7 +49,7 @@ def get_gist(request, apiuser, gistid, c if not has_superadmin_permission(apiuser): if gist.gist_owner != apiuser.user_id: - raise JSONRPCError('gist `{}` does not exist'.format(gistid)) + raise JSONRPCError(f'gist `{gistid}` does not exist') data = gist.get_api_data() if content: @@ -240,13 +240,13 @@ def delete_gist(request, apiuser, gistid gist = get_gist_or_error(gistid) if not has_superadmin_permission(apiuser): if gist.gist_owner != apiuser.user_id: - raise JSONRPCError('gist `{}` does not exist'.format(gistid)) + raise JSONRPCError(f'gist `{gistid}` does not exist') try: GistModel().delete(gist) Session().commit() return { - 'msg': 'deleted gist ID:{}'.format(gist.gist_access_id), + 'msg': f'deleted gist ID:{gist.gist_access_id}', 'gist': None } except Exception: diff --git a/rhodecode/api/views/pull_request_api.py b/rhodecode/api/views/pull_request_api.py --- a/rhodecode/api/views/pull_request_api.py +++ b/rhodecode/api/views/pull_request_api.py @@ -527,7 +527,7 @@ def comment_pull_request( if not PullRequestModel().check_user_read( pull_request, apiuser, api=True): - raise JSONRPCError('repository `{}` does not exist'.format(repoid)) + raise JSONRPCError(f'repository `{repoid}` does not exist') message = Optional.extract(message) status = Optional.extract(status) commit_id = Optional.extract(commit_id) @@ -1082,7 +1082,7 @@ def close_pull_request( if pull_request.is_closed(): raise JSONRPCError( - 'pull request `{}` is already closed'.format(pullrequestid)) + f'pull request `{pullrequestid}` is already closed') # only owner or admin or person with write permissions allowed_to_close = PullRequestModel().check_user_update( diff --git a/rhodecode/api/views/repo_api.py b/rhodecode/api/views/repo_api.py --- a/rhodecode/api/views/repo_api.py +++ b/rhodecode/api/views/repo_api.py @@ -918,13 +918,13 @@ def add_field_to_repo(request, apiuser, field_desc=description) Session().commit() return { - 'msg': "Added new repository field `{}`".format(key), + 'msg': f"Added new repository field `{key}`", 'success': True, } except Exception: log.exception("Exception occurred while trying to add field to repo") raise JSONRPCError( - 'failed to create new field for repository `{}`'.format(repoid)) + f'failed to create new field for repository `{repoid}`') @jsonrpc_method() @@ -957,14 +957,14 @@ def remove_field_from_repo(request, apiu RepoModel().delete_repo_field(repo, field_key=key) Session().commit() return { - 'msg': "Deleted repository field `{}`".format(key), + 'msg': f"Deleted repository field `{key}`", 'success': True, } except Exception: log.exception( "Exception occurred while trying to delete field from repo") raise JSONRPCError( - 'failed to delete field for repository `{}`'.format(repoid)) + f'failed to delete field for repository `{repoid}`') @jsonrpc_method() @@ -1130,7 +1130,7 @@ def update_repo( user=apiuser, repo=repo) Session().commit() return { - 'msg': 'updated repo ID:{} {}'.format(repo.repo_id, repo.repo_name), + 'msg': f'updated repo ID:{repo.repo_id} {repo.repo_name}', 'repository': repo.get_api_data(include_secrets=include_secrets) } except Exception: @@ -1351,13 +1351,13 @@ def delete_repo(request, apiuser, repoid ScmModel().mark_for_invalidation(repo_name, delete=True) Session().commit() return { - 'msg': 'Deleted repository `{}`{}'.format(repo_name, _forks_msg), + 'msg': f'Deleted repository `{repo_name}`{_forks_msg}', 'success': True } except Exception: log.exception("Exception occurred while trying to delete repo") raise JSONRPCError( - 'failed to delete repository `{}`'.format(repo_name) + f'failed to delete repository `{repo_name}`' ) @@ -1412,7 +1412,7 @@ def invalidate_cache(request, apiuser, r try: ScmModel().mark_for_invalidation(repo.repo_name, delete=delete) return { - 'msg': 'Cache for repository `{}` was invalidated'.format(repoid), + 'msg': f'Cache for repository `{repoid}` was invalidated', 'repository': repo.repo_name } except Exception: @@ -1706,7 +1706,7 @@ def comment_commit( except Exception: log.exception("Exception occurred while trying to comment on commit") raise JSONRPCError( - 'failed to set comment on repository `{}`'.format(repo.repo_name) + f'failed to set comment on repository `{repo.repo_name}`' ) @@ -1813,14 +1813,14 @@ def get_comment(request, apiuser, commen comment = ChangesetComment.get(comment_id) if not comment: - raise JSONRPCError('comment `{}` does not exist'.format(comment_id)) + raise JSONRPCError(f'comment `{comment_id}` does not exist') perms = ('repository.read', 'repository.write', 'repository.admin') has_comment_perm = HasRepoPermissionAnyApi(*perms)\ (user=apiuser, repo_name=comment.repo.repo_name) if not has_comment_perm: - raise JSONRPCError('comment `{}` does not exist'.format(comment_id)) + raise JSONRPCError(f'comment `{comment_id}` does not exist') return comment @@ -1858,7 +1858,7 @@ def edit_comment(request, apiuser, messa auth_user = apiuser comment = ChangesetComment.get(comment_id) if not comment: - raise JSONRPCError('comment `{}` does not exist'.format(comment_id)) + raise JSONRPCError(f'comment `{comment_id}` does not exist') is_super_admin = has_superadmin_permission(apiuser) is_repo_admin = HasRepoPermissionAnyApi('repository.admin')\ @@ -2120,7 +2120,7 @@ def grant_user_group_permission(request, if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') perm_additions = [[user_group.users_group_id, perm.permission_name, "user_group"]] try: @@ -2194,7 +2194,7 @@ def revoke_user_group_permission(request if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') perm_deletions = [[user_group.users_group_id, None, "user_group"]] try: diff --git a/rhodecode/api/views/repo_group_api.py b/rhodecode/api/views/repo_group_api.py --- a/rhodecode/api/views/repo_group_api.py +++ b/rhodecode/api/views/repo_group_api.py @@ -96,7 +96,7 @@ def get_repo_group(request, apiuser, rep if not HasRepoGroupPermissionAnyApi(*_perms)( user=apiuser, group_name=repo_group.group_name): raise JSONRPCError( - 'repository group `{}` does not exist'.format(repogroupid)) + f'repository group `{repogroupid}` does not exist') permissions = [] for _user in repo_group.permissions(): @@ -240,7 +240,7 @@ def create_repo_group( except Exception: log.exception("Exception occurred while trying create repo group") raise JSONRPCError( - 'failed to create repo group `{}`'.format(validated_group_name)) + f'failed to create repo group `{validated_group_name}`') @jsonrpc_method() @@ -627,7 +627,7 @@ def grant_user_group_permission_to_repo_ if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') apply_to_children = Optional.extract(apply_to_children) @@ -720,7 +720,7 @@ def revoke_user_group_permission_from_re if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') apply_to_children = Optional.extract(apply_to_children) diff --git a/rhodecode/api/views/user_api.py b/rhodecode/api/views/user_api.py --- a/rhodecode/api/views/user_api.py +++ b/rhodecode/api/views/user_api.py @@ -230,10 +230,10 @@ def create_user(request, apiuser, userna raise JSONRPCForbidden() if UserModel().get_by_username(username): - raise JSONRPCError("user `{}` already exist".format(username)) + raise JSONRPCError(f"user `{username}` already exist") if UserModel().get_by_email(email, case_insensitive=True): - raise JSONRPCError("email `{}` already exist".format(email)) + raise JSONRPCError(f"email `{email}` already exist") # generate random password if we actually given the # extern_name and it's not rhodecode @@ -303,7 +303,7 @@ def create_user(request, apiuser, userna } except Exception: log.exception('Error occurred during creation of user') - raise JSONRPCError('failed to create user `{}`'.format(username)) + raise JSONRPCError(f'failed to create user `{username}`') @jsonrpc_method() @@ -396,7 +396,7 @@ def update_user(request, apiuser, userid user=apiuser) Session().commit() return { - 'msg': 'updated user ID:{} {}'.format(user.user_id, user.username), + 'msg': f'updated user ID:{user.user_id} {user.username}', 'user': user.get_api_data(include_secrets=True) } except DefaultUserException: @@ -404,7 +404,7 @@ def update_user(request, apiuser, userid raise JSONRPCError('editing default user is forbidden') except Exception: log.exception("Error occurred during update of user") - raise JSONRPCError('failed to update user `{}`'.format(userid)) + raise JSONRPCError(f'failed to update user `{userid}`') @jsonrpc_method() @@ -465,13 +465,13 @@ def delete_user(request, apiuser, userid Session().commit() return { - 'msg': 'deleted user ID:{} {}'.format(user.user_id, user.username), + 'msg': f'deleted user ID:{user.user_id} {user.username}', 'user': None } except Exception: log.exception("Error occurred during deleting of user") raise JSONRPCError( - 'failed to delete user ID:{} {}'.format(user.user_id, user.username)) + f'failed to delete user ID:{user.user_id} {user.username}') @jsonrpc_method() diff --git a/rhodecode/api/views/user_group_api.py b/rhodecode/api/views/user_group_api.py --- a/rhodecode/api/views/user_group_api.py +++ b/rhodecode/api/views/user_group_api.py @@ -224,7 +224,7 @@ def create_user_group( raise JSONRPCForbidden() if UserGroupModel().get_by_name(group_name): - raise JSONRPCError("user group `{}` already exist".format(group_name)) + raise JSONRPCError(f"user group `{group_name}` already exist") if isinstance(owner, Optional): owner = apiuser.user_id @@ -277,7 +277,7 @@ def create_user_group( } except Exception: log.exception("Error occurred during creation of user group") - raise JSONRPCError('failed to create group `{}`'.format(group_name)) + raise JSONRPCError(f'failed to create group `{group_name}`') @jsonrpc_method() @@ -339,7 +339,7 @@ def update_user_group(request, apiuser, if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') else: include_secrets = True @@ -380,7 +380,7 @@ def update_user_group(request, apiuser, except Exception: log.exception("Error occurred during update of user group") raise JSONRPCError( - 'failed to update user group `{}`'.format(usergroupid)) + f'failed to update user group `{usergroupid}`') @jsonrpc_method() @@ -429,7 +429,7 @@ def delete_user_group(request, apiuser, if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') old_data = user_group.get_api_data() try: @@ -577,7 +577,7 @@ def remove_user_from_user_group(request, if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') old_values = user_group.get_api_data() try: @@ -639,7 +639,7 @@ def grant_user_permission_to_user_group( if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') user = get_user_or_error(userid) perm = get_perm_or_error(perm, prefix='usergroup.') @@ -711,7 +711,7 @@ def revoke_user_permission_from_user_gro if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(usergroupid)) + f'user group `{usergroupid}` does not exist') user = get_user_or_error(userid) @@ -782,14 +782,14 @@ def grant_user_group_permission_to_user_ user=apiuser, user_group_name=target_user_group.users_group_name): raise JSONRPCError( - 'to user group `{}` does not exist'.format(usergroupid)) + f'to user group `{usergroupid}` does not exist') # check if we have at least read permission for source user group ! _perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin',) if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(sourceusergroupid)) + f'user group `{sourceusergroupid}` does not exist') try: changes = UserGroupModel().grant_user_group_permission( @@ -862,7 +862,7 @@ def revoke_user_group_permission_from_us user=apiuser, user_group_name=target_user_group.users_group_name): raise JSONRPCError( - 'to user group `{}` does not exist'.format(usergroupid)) + f'to user group `{usergroupid}` does not exist') # check if we have at least read permission # for the source user group ! @@ -870,7 +870,7 @@ def revoke_user_group_permission_from_us if not HasUserGroupPermissionAnyApi(*_perms)( user=apiuser, user_group_name=user_group.users_group_name): raise JSONRPCError( - 'user group `{}` does not exist'.format(sourceusergroupid)) + f'user group `{sourceusergroupid}` does not exist') try: changes = UserGroupModel().revoke_user_group_permission( diff --git a/rhodecode/apps/_base/__init__.py b/rhodecode/apps/_base/__init__.py --- a/rhodecode/apps/_base/__init__.py +++ b/rhodecode/apps/_base/__init__.py @@ -92,7 +92,7 @@ def _format_ref_id(name, raw_id): def _format_ref_id_svn(name, raw_id): """Special way of formatting a reference for Subversion including path""" - return '{}@{}'.format(name, raw_id) + return f'{name}@{raw_id}' class TemplateArgs(StrictAttributeDict): diff --git a/rhodecode/apps/admin/__init__.py b/rhodecode/apps/admin/__init__.py --- a/rhodecode/apps/admin/__init__.py +++ b/rhodecode/apps/admin/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/admin/views/users.py b/rhodecode/apps/admin/views/users.py --- a/rhodecode/apps/admin/views/users.py +++ b/rhodecode/apps/admin/views/users.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -258,7 +256,7 @@ class UsersView(UserAppView): except Exception: log.exception( - 'Could not extend user plugins with `{}`'.format(extern_type)) + f'Could not extend user plugins with `{extern_type}`') return valid_plugins def load_default_context(self): @@ -758,18 +756,18 @@ class UsersView(UserAppView): named_personal_group.personal = True Session().add(named_personal_group) Session().commit() - msg = _('Linked repository group `%s` as personal' % ( - personal_repo_group_name,)) + msg = _('Linked repository group `{}` as personal'.format( + personal_repo_group_name)) h.flash(msg, category='success') elif not named_personal_group: RepoGroupModel().create_personal_repo_group(c.user) - msg = _('Created repository group `%s`' % ( - personal_repo_group_name,)) + msg = _('Created repository group `{}`'.format( + personal_repo_group_name)) h.flash(msg, category='success') else: - msg = _('Repository group `%s` is already taken' % ( - personal_repo_group_name,)) + msg = _('Repository group `{}` is already taken'.format( + personal_repo_group_name)) h.flash(msg, category='warning') except Exception: log.exception("Exception during repository group creation") @@ -1296,7 +1294,7 @@ class UsersView(UserAppView): c.active = 'caches' c.perm_user = c.user.AuthUser(ip_addr=self.request.remote_addr) - cache_namespace_uid = 'cache_user_auth.{}'.format(self.db_user.user_id) + cache_namespace_uid = f'cache_user_auth.{self.db_user.user_id}' c.region = rc_cache.get_or_create_region('cache_perms', cache_namespace_uid) c.backend = c.region.backend c.user_keys = sorted(c.region.backend.list_keys(prefix=cache_namespace_uid)) @@ -1314,7 +1312,7 @@ class UsersView(UserAppView): c.active = 'caches' c.perm_user = c.user.AuthUser(ip_addr=self.request.remote_addr) - cache_namespace_uid = 'cache_user_auth.{}'.format(self.db_user.user_id) + cache_namespace_uid = f'cache_user_auth.{self.db_user.user_id}' del_keys = rc_cache.clear_cache_namespace('cache_perms', cache_namespace_uid) h.flash(_("Deleted {} cache keys").format(del_keys), category='success') diff --git a/rhodecode/apps/channelstream/__init__.py b/rhodecode/apps/channelstream/__init__.py --- a/rhodecode/apps/channelstream/__init__.py +++ b/rhodecode/apps/channelstream/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/channelstream/views.py b/rhodecode/apps/channelstream/views.py --- a/rhodecode/apps/channelstream/views.py +++ b/rhodecode/apps/channelstream/views.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -115,7 +114,7 @@ class ChannelstreamView(BaseAppView): self.channelstream_config, payload, '/connect') except ChannelstreamConnectionException: log.exception( - 'Channelstream service at {} is down'.format(channelstream_url)) + f'Channelstream service at {channelstream_url} is down') return HTTPBadGateway() channel_info = connect_result.get('channels_info') @@ -167,7 +166,7 @@ class ChannelstreamView(BaseAppView): self.channelstream_config, payload, '/subscribe') except ChannelstreamConnectionException: log.exception( - 'Channelstream service at {} is down'.format(channelstream_url)) + f'Channelstream service at {channelstream_url} is down') return HTTPBadGateway() channel_info = connect_result.get('channels_info') diff --git a/rhodecode/apps/file_store/__init__.py b/rhodecode/apps/file_store/__init__.py --- a/rhodecode/apps/file_store/__init__.py +++ b/rhodecode/apps/file_store/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/file_store/backends/__init__.py b/rhodecode/apps/file_store/backends/__init__.py --- a/rhodecode/apps/file_store/backends/__init__.py +++ b/rhodecode/apps/file_store/backends/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/file_store/backends/local_store.py b/rhodecode/apps/file_store/backends/local_store.py --- a/rhodecode/apps/file_store/backends/local_store.py +++ b/rhodecode/apps/file_store/backends/local_store.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -107,7 +105,7 @@ class LocalFileStorage(object): self.extensions = resolve_extensions([], groups=extension_groups) def __repr__(self): - return '{}@{}'.format(self.__class__, self.base_path) + return f'{self.__class__}@{self.base_path}' def store_path(self, filename): """ diff --git a/rhodecode/apps/file_store/config_keys.py b/rhodecode/apps/file_store/config_keys.py --- a/rhodecode/apps/file_store/config_keys.py +++ b/rhodecode/apps/file_store/config_keys.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/file_store/exceptions.py b/rhodecode/apps/file_store/exceptions.py --- a/rhodecode/apps/file_store/exceptions.py +++ b/rhodecode/apps/file_store/exceptions.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/file_store/extensions.py b/rhodecode/apps/file_store/extensions.py --- a/rhodecode/apps/file_store/extensions.py +++ b/rhodecode/apps/file_store/extensions.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -57,7 +55,7 @@ def resolve_extensions(extensions, group :param groups: additionally groups to extend the extensions. """ groups = groups or [] - valid_exts = set([x.lower() for x in extensions]) + valid_exts = {x.lower() for x in extensions} for group in groups: if group in GROUPS: diff --git a/rhodecode/apps/file_store/tests/__init__.py b/rhodecode/apps/file_store/tests/__init__.py --- a/rhodecode/apps/file_store/tests/__init__.py +++ b/rhodecode/apps/file_store/tests/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/file_store/tests/test_upload_file.py b/rhodecode/apps/file_store/tests/test_upload_file.py --- a/rhodecode/apps/file_store/tests/test_upload_file.py +++ b/rhodecode/apps/file_store/tests/test_upload_file.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -102,9 +101,9 @@ class TestFileStoreViews(TestController) status=200) assert response.json == { - u'error': u'store_file data field is missing', - u'access_path': None, - u'store_fid': None} + 'error': 'store_file data field is missing', + 'access_path': None, + 'store_fid': None} def test_upload_files_bogus_content_to_store(self): self.log_user() @@ -114,9 +113,9 @@ class TestFileStoreViews(TestController) status=200) assert response.json == { - u'error': u'filename cannot be read from the data field', - u'access_path': None, - u'store_fid': None} + 'error': 'filename cannot be read from the data field', + 'access_path': None, + 'store_fid': None} def test_upload_content_to_store(self): self.log_user() diff --git a/rhodecode/apps/file_store/utils.py b/rhodecode/apps/file_store/utils.py --- a/rhodecode/apps/file_store/utils.py +++ b/rhodecode/apps/file_store/utils.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/file_store/views.py b/rhodecode/apps/file_store/views.py --- a/rhodecode/apps/file_store/views.py +++ b/rhodecode/apps/file_store/views.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -118,7 +116,7 @@ class FileStoreView(BaseAppView): file_name = db_obj.file_display_name response.headers["Content-Disposition"] = ( - 'attachment; filename="{}"'.format(str(file_name)) + f'attachment; filename="{str(file_name)}"' ) response.headers["X-RC-Artifact-Id"] = str(db_obj.file_store_id) response.headers["X-RC-Artifact-Desc"] = str(db_obj.file_description) @@ -135,7 +133,7 @@ class FileStoreView(BaseAppView): if file_obj is None: return {'store_fid': None, 'access_path': None, - 'error': '{} data field is missing'.format(self.upload_key)} + 'error': f'{self.upload_key} data field is missing'} if not hasattr(file_obj, 'filename'): return {'store_fid': None, @@ -154,18 +152,18 @@ class FileStoreView(BaseAppView): except FileNotAllowedException: return {'store_fid': None, 'access_path': None, - 'error': 'File {} is not allowed.'.format(filename)} + 'error': f'File {filename} is not allowed.'} except FileOverSizeException: return {'store_fid': None, 'access_path': None, - 'error': 'File {} is exceeding allowed limit.'.format(filename)} + 'error': f'File {filename} is exceeding allowed limit.'} try: entry = FileStore.create( file_uid=store_uid, filename=metadata["filename"], file_hash=metadata["sha256"], file_size=metadata["size"], - file_description=u'upload attachment', + file_description='upload attachment', check_acl=False, user_id=self._rhodecode_user.user_id ) Session().add(entry) @@ -175,7 +173,7 @@ class FileStoreView(BaseAppView): log.exception('Failed to store file %s', filename) return {'store_fid': None, 'access_path': None, - 'error': 'File {} failed to store in DB.'.format(filename)} + 'error': f'File {filename} failed to store in DB.'} return {'store_fid': store_uid, 'access_path': h.route_path('download_file', fid=store_uid)} diff --git a/rhodecode/apps/gist/__init__.py b/rhodecode/apps/gist/__init__.py --- a/rhodecode/apps/gist/__init__.py +++ b/rhodecode/apps/gist/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/gist/tests/__init__.py b/rhodecode/apps/gist/tests/__init__.py --- a/rhodecode/apps/gist/tests/__init__.py +++ b/rhodecode/apps/gist/tests/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/gist/tests/test_admin_gists.py b/rhodecode/apps/gist/tests/test_admin_gists.py --- a/rhodecode/apps/gist/tests/test_admin_gists.py +++ b/rhodecode/apps/gist/tests/test_admin_gists.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/gist/views.py b/rhodecode/apps/gist/views.py --- a/rhodecode/apps/gist/views.py +++ b/rhodecode/apps/gist/views.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2013-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/__init__.py b/rhodecode/apps/home/__init__.py --- a/rhodecode/apps/home/__init__.py +++ b/rhodecode/apps/home/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/tests/__init__.py b/rhodecode/apps/home/tests/__init__.py --- a/rhodecode/apps/home/tests/__init__.py +++ b/rhodecode/apps/home/tests/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/tests/test_get_goto_switched_data.py b/rhodecode/apps/home/tests/test_get_goto_switched_data.py --- a/rhodecode/apps/home/tests/test_get_goto_switched_data.py +++ b/rhodecode/apps/home/tests/test_get_goto_switched_data.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/tests/test_get_repo_list_data.py b/rhodecode/apps/home/tests/test_get_repo_list_data.py --- a/rhodecode/apps/home/tests/test_get_repo_list_data.py +++ b/rhodecode/apps/home/tests/test_get_repo_list_data.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/tests/test_get_user_data.py b/rhodecode/apps/home/tests/test_get_user_data.py --- a/rhodecode/apps/home/tests/test_get_user_data.py +++ b/rhodecode/apps/home/tests/test_get_user_data.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/tests/test_get_user_group_data.py b/rhodecode/apps/home/tests/test_get_user_group_data.py --- a/rhodecode/apps/home/tests/test_get_user_group_data.py +++ b/rhodecode/apps/home/tests/test_get_user_group_data.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/tests/test_home.py b/rhodecode/apps/home/tests/test_home.py --- a/rhodecode/apps/home/tests/test_home.py +++ b/rhodecode/apps/home/tests/test_home.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/home/views.py b/rhodecode/apps/home/views.py --- a/rhodecode/apps/home/views.py +++ b/rhodecode/apps/home/views.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -129,7 +127,7 @@ class HomeView(BaseAppView, DataGridAppV query = query.filter(Repository.repo_type == repo_type) if name_contains: - ilike_expression = '%{}%'.format(safe_str(name_contains)) + ilike_expression = f'%{safe_str(name_contains)}%' query = query.filter( Repository.repo_name.ilike(ilike_expression)) query = query.limit(limit) @@ -174,7 +172,7 @@ class HomeView(BaseAppView, DataGridAppV query = query.order_by(RepoGroup.group_name) if name_contains: - ilike_expression = u'%{}%'.format(safe_str(name_contains)) + ilike_expression = f'%{safe_str(name_contains)}%' query = query.filter( RepoGroup.group_name.ilike(ilike_expression)) query = query.limit(limit) @@ -216,7 +214,7 @@ class HomeView(BaseAppView, DataGridAppV .filter(User.username != User.DEFAULT_USER) if name_contains: - ilike_expression = u'%{}%'.format(safe_str(name_contains)) + ilike_expression = f'%{safe_str(name_contains)}%' query = query.filter( User.username.ilike(ilike_expression)) query = query.limit(limit) @@ -227,7 +225,7 @@ class HomeView(BaseAppView, DataGridAppV { 'id': obj.user_id, 'value': org_query, - 'value_display': 'user: `{}`'.format(obj.username), + 'value_display': f'user: `{obj.username}`', 'type': 'user', 'icon_link': h.gravatar_url(obj.email, 30, request=self.request), 'url': h.route_path( @@ -256,7 +254,7 @@ class HomeView(BaseAppView, DataGridAppV .order_by(UserGroup.users_group_name) if name_contains: - ilike_expression = u'%{}%'.format(safe_str(name_contains)) + ilike_expression = f'%{safe_str(name_contains)}%' query = query.filter( UserGroup.users_group_name.ilike(ilike_expression)) query = query.limit(limit) @@ -267,7 +265,7 @@ class HomeView(BaseAppView, DataGridAppV { 'id': obj.users_group_id, 'value': org_query, - 'value_display': 'user_group: `{}`'.format(obj.users_group_name), + 'value_display': f'user_group: `{obj.users_group_name}`', 'type': 'user_group', 'url': h.route_path( 'user_group_profile', user_group_name=obj.users_group_name) @@ -308,7 +306,7 @@ class HomeView(BaseAppView, DataGridAppV query = query.order_by(PullRequest.pull_request_id) if name_contains: - ilike_expression = u'%{}%'.format(safe_str(name_contains)) + ilike_expression = f'%{safe_str(name_contains)}%' query = query.filter(or_( cast(PullRequest.pull_request_id, String).ilike(ilike_expression), PullRequest.title.ilike(ilike_expression), @@ -349,7 +347,7 @@ class HomeView(BaseAppView, DataGridAppV commit_hash = commit_hashes[0] result = searcher.search( - 'commit_id:{}*'.format(commit_hash), 'commit', auth_user, + f'commit_id:{commit_hash}*', 'commit', auth_user, repo_name, repo_group_name, raise_on_exc=False) commits = [] @@ -396,7 +394,7 @@ class HomeView(BaseAppView, DataGridAppV search_path = searcher.escape_specials(file_path) result = searcher.search( - 'file.raw:*{}*'.format(search_path), 'path', auth_user, + f'file.raw:*{search_path}*', 'path', auth_user, repo_name, repo_group_name, raise_on_exc=False) files = [] @@ -495,7 +493,7 @@ class HomeView(BaseAppView, DataGridAppV qry = query return {'q': qry, 'type': 'content'} - label = u'File content search for `{}`'.format(h.escape(query)) + label = f'File content search for `{h.escape(query)}`' file_qry = { 'id': -10, 'value': query, @@ -513,7 +511,7 @@ class HomeView(BaseAppView, DataGridAppV qry = query return {'q': qry, 'type': 'commit'} - label = u'Commit search for `{}`'.format(h.escape(query)) + label = f'Commit search for `{h.escape(query)}`' commit_qry = { 'id': -20, 'value': query, @@ -539,7 +537,7 @@ class HomeView(BaseAppView, DataGridAppV qry = query return {'q': qry, 'type': 'content'} - label = u'File content search for `{}`'.format(query) + label = f'File content search for `{query}`' file_qry = { 'id': -30, 'value': query, @@ -557,7 +555,7 @@ class HomeView(BaseAppView, DataGridAppV qry = query return {'q': qry, 'type': 'commit'} - label = u'Commit search for `{}`'.format(query) + label = f'Commit search for `{query}`' commit_qry = { 'id': -40, 'value': query, @@ -583,7 +581,7 @@ class HomeView(BaseAppView, DataGridAppV { 'id': -1, 'value': query, - 'value_display': u'File content search for: `{}`'.format(query), + 'value_display': f'File content search for: `{query}`', 'value_icon': '', 'type': 'search', 'subtype': 'global', @@ -594,7 +592,7 @@ class HomeView(BaseAppView, DataGridAppV { 'id': -2, 'value': query, - 'value_display': u'Commit search for: `{}`'.format(query), + 'value_display': f'Commit search for: `{query}`', 'value_icon': '', 'type': 'search', 'subtype': 'global', @@ -853,4 +851,4 @@ class HomeView(BaseAppView, DataGridAppV if existing_value != val: self.request.session[key] = val - return 'stored:{}:{}'.format(key, val) + return f'stored:{key}:{val}' diff --git a/rhodecode/apps/hovercards/__init__.py b/rhodecode/apps/hovercards/__init__.py --- a/rhodecode/apps/hovercards/__init__.py +++ b/rhodecode/apps/hovercards/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2018-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/hovercards/views.py b/rhodecode/apps/hovercards/views.py --- a/rhodecode/apps/hovercards/views.py +++ b/rhodecode/apps/hovercards/views.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/journal/__init__.py b/rhodecode/apps/journal/__init__.py --- a/rhodecode/apps/journal/__init__.py +++ b/rhodecode/apps/journal/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/journal/tests/__init__.py b/rhodecode/apps/journal/tests/__init__.py --- a/rhodecode/apps/journal/tests/__init__.py +++ b/rhodecode/apps/journal/tests/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/journal/views.py b/rhodecode/apps/journal/views.py --- a/rhodecode/apps/journal/views.py +++ b/rhodecode/apps/journal/views.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/login/__init__.py b/rhodecode/apps/login/__init__.py --- a/rhodecode/apps/login/__init__.py +++ b/rhodecode/apps/login/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/login/tests/test_login.py b/rhodecode/apps/login/tests/test_login.py --- a/rhodecode/apps/login/tests/test_login.py +++ b/rhodecode/apps/login/tests/test_login.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/login/tests/test_password_reset.py b/rhodecode/apps/login/tests/test_password_reset.py --- a/rhodecode/apps/login/tests/test_password_reset.py +++ b/rhodecode/apps/login/tests/test_password_reset.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/login/tests/test_register_captcha.py b/rhodecode/apps/login/tests/test_register_captcha.py --- a/rhodecode/apps/login/tests/test_register_captcha.py +++ b/rhodecode/apps/login/tests/test_register_captcha.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/login/views.py b/rhodecode/apps/login/views.py --- a/rhodecode/apps/login/views.py +++ b/rhodecode/apps/login/views.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -370,7 +368,7 @@ class LoginView(BaseAppView): return HTTPFound(self.request.route_path('reset_password')) password_reset_form = PasswordResetForm(self.request.translate)() - description = u'Generated token for password reset from {}'.format( + description = 'Generated token for password reset from {}'.format( datetime.datetime.now().isoformat()) try: diff --git a/rhodecode/apps/my_account/__init__.py b/rhodecode/apps/my_account/__init__.py --- a/rhodecode/apps/my_account/__init__.py +++ b/rhodecode/apps/my_account/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/my_account/tests/__init__.py b/rhodecode/apps/my_account/tests/__init__.py --- a/rhodecode/apps/my_account/tests/__init__.py +++ b/rhodecode/apps/my_account/tests/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/my_account/tests/test_my_account_auth_tokens.py b/rhodecode/apps/my_account/tests/test_my_account_auth_tokens.py --- a/rhodecode/apps/my_account/tests/test_my_account_auth_tokens.py +++ b/rhodecode/apps/my_account/tests/test_my_account_auth_tokens.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/my_account/tests/test_my_account_edit.py b/rhodecode/apps/my_account/tests/test_my_account_edit.py --- a/rhodecode/apps/my_account/tests/test_my_account_edit.py +++ b/rhodecode/apps/my_account/tests/test_my_account_edit.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -87,8 +85,8 @@ class TestMyAccountEdit(TestController): response = self.app.get(route_path('my_account_pullrequests_data'), extra_environ=xhr_header) assert response.json == { - u'data': [], u'draw': None, - u'recordsFiltered': 0, u'recordsTotal': 0} + 'data': [], 'draw': None, + 'recordsFiltered': 0, 'recordsTotal': 0} pr = pr_util.create_pull_request(title='TestMyAccountPR') expected = { @@ -115,7 +113,7 @@ class TestMyAccountEdit(TestController): # ('extern_name', {'extern_name': None}), ('active', {'active': False}), ('active', {'active': True}), - ('email', {'email': u'some@email.com'}), + ('email', {'email': 'some@email.com'}), ]) def test_my_account_update(self, name, attrs, user_util): usr = user_util.create_user(password='qweqwe') @@ -126,8 +124,8 @@ class TestMyAccountEdit(TestController): params.update({'password_confirmation': ''}) params.update({'new_password': ''}) - params.update({'extern_type': u'rhodecode'}) - params.update({'extern_name': u'rhodecode'}) + params.update({'extern_type': 'rhodecode'}) + params.update({'extern_name': 'rhodecode'}) params.update({'csrf_token': self.csrf_token}) params.update(attrs) diff --git a/rhodecode/apps/my_account/tests/test_my_account_emails.py b/rhodecode/apps/my_account/tests/test_my_account_emails.py --- a/rhodecode/apps/my_account/tests/test_my_account_emails.py +++ b/rhodecode/apps/my_account/tests/test_my_account_emails.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/my_account/tests/test_my_account_notifications.py b/rhodecode/apps/my_account/tests/test_my_account_notifications.py --- a/rhodecode/apps/my_account/tests/test_my_account_notifications.py +++ b/rhodecode/apps/my_account/tests/test_my_account_notifications.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/repository/tests/test_pull_requests_list.py b/rhodecode/apps/repository/tests/test_pull_requests_list.py --- a/rhodecode/apps/repository/tests/test_pull_requests_list.py +++ b/rhodecode/apps/repository/tests/test_pull_requests_list.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/repository/tests/test_repo_bookmarks.py b/rhodecode/apps/repository/tests/test_repo_bookmarks.py --- a/rhodecode/apps/repository/tests/test_repo_bookmarks.py +++ b/rhodecode/apps/repository/tests/test_repo_bookmarks.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/repository/tests/test_repo_branches.py b/rhodecode/apps/repository/tests/test_repo_branches.py --- a/rhodecode/apps/repository/tests/test_repo_branches.py +++ b/rhodecode/apps/repository/tests/test_repo_branches.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/repository/tests/test_repo_changelog.py b/rhodecode/apps/repository/tests/test_repo_changelog.py --- a/rhodecode/apps/repository/tests/test_repo_changelog.py +++ b/rhodecode/apps/repository/tests/test_repo_changelog.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -107,7 +106,7 @@ class TestChangelogController(TestContro repo=backend.repo_name, branch=branch) assert expected_url in response.location response = response.follow() - expected_warning = 'Branch {} is not found.'.format(branch) + expected_warning = f'Branch {branch} is not found.' assert expected_warning in response.text @pytest.mark.xfail_backends("svn", reason="Depends on branch support") diff --git a/rhodecode/apps/repository/tests/test_repo_commit_comments.py b/rhodecode/apps/repository/tests/test_repo_commit_comments.py --- a/rhodecode/apps/repository/tests/test_repo_commit_comments.py +++ b/rhodecode/apps/repository/tests/test_repo_commit_comments.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py --- a/rhodecode/apps/repository/views/repo_files.py +++ b/rhodecode/apps/repository/views/repo_files.py @@ -996,7 +996,7 @@ class RepoFilesView(RepoAppView): commits_group = ([], _("Changesets")) for commit in commits: branch = ' (%s)' % commit.branch if commit.branch else '' - n_desc = 'r{}:{}{}'.format(commit.idx, commit.short_id, branch) + n_desc = f'r{commit.idx}:{commit.short_id}{branch}' commits_group[0].append((commit.raw_id, n_desc, 'sha')) history.append(commits_group) diff --git a/rhodecode/apps/repository/views/repo_settings_vcs.py b/rhodecode/apps/repository/views/repo_settings_vcs.py --- a/rhodecode/apps/repository/views/repo_settings_vcs.py +++ b/rhodecode/apps/repository/views/repo_settings_vcs.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2017-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -53,7 +51,7 @@ class RepoSettingsVcsView(RepoAppView): repo_defaults.update(model.get_repo_settings()) global_defaults = { - '{}_inherited'.format(k): global_defaults[k] + f'{k}_inherited': global_defaults[k] for k in global_defaults} defaults = { diff --git a/rhodecode/apps/repository/views/repo_strip.py b/rhodecode/apps/repository/views/repo_strip.py --- a/rhodecode/apps/repository/views/repo_strip.py +++ b/rhodecode/apps/repository/views/repo_strip.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2017-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/ssh_support/lib/backends/__init__.py b/rhodecode/apps/ssh_support/lib/backends/__init__.py --- a/rhodecode/apps/ssh_support/lib/backends/__init__.py +++ b/rhodecode/apps/ssh_support/lib/backends/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -207,7 +205,7 @@ class SshWrapper(object): return server.run(tunnel_extras=extras) else: - raise Exception('Unrecognised VCS: {}'.format(vcs)) + raise Exception(f'Unrecognised VCS: {vcs}') def wrap(self): mode = self.mode diff --git a/rhodecode/apps/user_group/tests/__init__.py b/rhodecode/apps/user_group/tests/__init__.py --- a/rhodecode/apps/user_group/tests/__init__.py +++ b/rhodecode/apps/user_group/tests/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/apps/user_group/tests/test_user_groups.py b/rhodecode/apps/user_group/tests/test_user_groups.py --- a/rhodecode/apps/user_group/tests/test_user_groups.py +++ b/rhodecode/apps/user_group/tests/test_user_groups.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/authentication/base.py b/rhodecode/authentication/base.py --- a/rhodecode/authentication/base.py +++ b/rhodecode/authentication/base.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/config/__init__.py b/rhodecode/config/__init__.py --- a/rhodecode/config/__init__.py +++ b/rhodecode/config/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/config/conf.py b/rhodecode/config/conf.py --- a/rhodecode/config/conf.py +++ b/rhodecode/config/conf.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2013-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/config/environment.py b/rhodecode/config/environment.py --- a/rhodecode/config/environment.py +++ b/rhodecode/config/environment.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -260,11 +259,11 @@ def error_handler(exception, request): statsd = request.registry.statsd if statsd and base_response.status_code > 499: - exc_type = "{}.{}".format(exception.__class__.__module__, exception.__class__.__name__) + exc_type = f"{exception.__class__.__module__}.{exception.__class__.__name__}" statsd.incr('rhodecode_exception_total', tags=["exc_source:web", - "http_code:{}".format(base_response.status_code), - "type:{}".format(exc_type)]) + f"http_code:{base_response.status_code}", + f"type:{exc_type}"]) return response diff --git a/rhodecode/config/patches.py b/rhodecode/config/patches.py --- a/rhodecode/config/patches.py +++ b/rhodecode/config/patches.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -69,7 +67,7 @@ def inspect_getargspec(): func = func.__wrapped__ id_func = id(func) if id_func in memo: - raise ValueError('wrapper loop when unwrapping {!r}'.format(f)) + raise ValueError(f'wrapper loop when unwrapping {f!r}') memo.add(id_func) return func diff --git a/rhodecode/config/settings_maker.py b/rhodecode/config/settings_maker.py --- a/rhodecode/config/settings_maker.py +++ b/rhodecode/config/settings_maker.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -70,7 +69,7 @@ class SettingsMaker(object): os.makedirs(input_val, mode=mode) if not os.path.isdir(input_val): - raise Exception('Dir at {} does not exist'.format(input_val)) + raise Exception(f'Dir at {input_val} does not exist') return input_val @classmethod diff --git a/rhodecode/config/utils.py b/rhodecode/config/utils.py --- a/rhodecode/config/utils.py +++ b/rhodecode/config/utils.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/events/base.py b/rhodecode/events/base.py --- a/rhodecode/events/base.py +++ b/rhodecode/events/base.py @@ -45,7 +45,7 @@ class RhodecodeEvent(object): self.utc_timestamp = datetime.datetime.utcnow() def __repr__(self): - return '<%s:(%s)>' % (self.__class__.__name__, self.name) + return '<{}:({})>'.format(self.__class__.__name__, self.name) def get_request(self): if self._request: diff --git a/rhodecode/events/pullrequest.py b/rhodecode/events/pullrequest.py --- a/rhodecode/events/pullrequest.py +++ b/rhodecode/events/pullrequest.py @@ -32,13 +32,13 @@ class PullRequestEvent(RepoEvent): """ def __init__(self, pullrequest): - super(PullRequestEvent, self).__init__(pullrequest.target_repo) + super().__init__(pullrequest.target_repo) self.pullrequest = pullrequest def as_dict(self): from rhodecode.lib.utils2 import md5_safe from rhodecode.model.pull_request import PullRequestModel - data = super(PullRequestEvent, self).as_dict() + data = super().as_dict() commits = _commits_as_dict( self, @@ -110,7 +110,7 @@ class PullRequestReviewEvent(PullRequest 'pull requests has changed to other.') def __init__(self, pullrequest, status): - super(PullRequestReviewEvent, self).__init__(pullrequest) + super().__init__(pullrequest) self.status = status @@ -136,12 +136,12 @@ class PullRequestCommentEvent(PullReques 'in the pull request') def __init__(self, pullrequest, comment): - super(PullRequestCommentEvent, self).__init__(pullrequest) + super().__init__(pullrequest) self.comment = comment def as_dict(self): from rhodecode.model.comment import CommentsModel - data = super(PullRequestCommentEvent, self).as_dict() + data = super().as_dict() status = None if self.comment.status_change: @@ -175,12 +175,12 @@ class PullRequestCommentEditEvent(PullRe 'in the pull request') def __init__(self, pullrequest, comment): - super(PullRequestCommentEditEvent, self).__init__(pullrequest) + super().__init__(pullrequest) self.comment = comment def as_dict(self): from rhodecode.model.comment import CommentsModel - data = super(PullRequestCommentEditEvent, self).as_dict() + data = super().as_dict() status = None if self.comment.status_change: diff --git a/rhodecode/events/repo.py b/rhodecode/events/repo.py --- a/rhodecode/events/repo.py +++ b/rhodecode/events/repo.py @@ -69,7 +69,7 @@ def _commits_as_dict(event, commit_ids, 'raw_id': commit_id, 'short_id': commit_id, 'branch': None, 'git_ref_change': 'tag_add', - 'message': 'Added new tag {}'.format(raw_id), + 'message': f'Added new tag {raw_id}', 'author': event.actor.full_contact, 'date': datetime.datetime.now(), 'refs': { @@ -86,7 +86,7 @@ def _commits_as_dict(event, commit_ids, 'raw_id': commit_id, 'short_id': commit_id, 'branch': None, 'git_ref_change': 'branch_delete', - 'message': 'Deleted branch {}'.format(raw_id), + 'message': f'Deleted branch {raw_id}', 'author': event.actor.full_contact, 'date': datetime.datetime.now(), 'refs': { @@ -155,12 +155,12 @@ class RepoEvent(RhodeCodeIntegrationEven """ def __init__(self, repo): - super(RepoEvent, self).__init__() + super().__init__() self.repo = repo def as_dict(self): from rhodecode.model.repo import RepoModel - data = super(RepoEvent, self).as_dict() + data = super().as_dict() extra_fields = collections.OrderedDict() for field in self.repo.extra_fields: @@ -193,12 +193,12 @@ class RepoCommitCommentEvent(RepoEvent): 'on commit inside a repository') def __init__(self, repo, commit, comment): - super(RepoCommitCommentEvent, self).__init__(repo) + super().__init__(repo) self.commit = commit self.comment = comment def as_dict(self): - data = super(RepoCommitCommentEvent, self).as_dict() + data = super().as_dict() data['commit'] = { 'commit_id': self.commit.raw_id, 'commit_message': self.commit.message, @@ -228,12 +228,12 @@ class RepoCommitCommentEditEvent(RepoEve 'on commit inside a repository') def __init__(self, repo, commit, comment): - super(RepoCommitCommentEditEvent, self).__init__(repo) + super().__init__(repo) self.commit = commit self.comment = comment def as_dict(self): - data = super(RepoCommitCommentEditEvent, self).as_dict() + data = super().as_dict() data['commit'] = { 'commit_id': self.commit.raw_id, 'commit_message': self.commit.message, @@ -300,7 +300,7 @@ class RepoVCSEvent(RepoEvent): if not self.repo: raise Exception('repo by this name %s does not exist' % repo_name) self.extras = extras - super(RepoVCSEvent, self).__init__(self.repo) + super().__init__(self.repo) @property def actor(self): @@ -366,12 +366,12 @@ class RepoPushEvent(RepoVCSEvent): 'pushed to a repository') def __init__(self, repo_name, pushed_commit_ids, extras): - super(RepoPushEvent, self).__init__(repo_name, extras) + super().__init__(repo_name, extras) self.pushed_commit_ids = pushed_commit_ids self.new_refs = extras.new_refs def as_dict(self): - data = super(RepoPushEvent, self).as_dict() + data = super().as_dict() def branch_url(branch_name): return '{}/changelog?branch={}'.format( diff --git a/rhodecode/events/repo_group.py b/rhodecode/events/repo_group.py --- a/rhodecode/events/repo_group.py +++ b/rhodecode/events/repo_group.py @@ -33,11 +33,11 @@ class RepoGroupEvent(RhodeCodeIntegratio """ def __init__(self, repo_group): - super(RepoGroupEvent, self).__init__() + super().__init__() self.repo_group = repo_group def as_dict(self): - data = super(RepoGroupEvent, self).as_dict() + data = super().as_dict() data.update({ 'repo_group': { 'group_id': self.repo_group.group_id, diff --git a/rhodecode/events/user.py b/rhodecode/events/user.py --- a/rhodecode/events/user.py +++ b/rhodecode/events/user.py @@ -37,7 +37,7 @@ class UserRegistered(RhodeCodeIntegratio display_name = lazy_ugettext('user registered') def __init__(self, user, session): - super(UserRegistered, self).__init__() + super().__init__() self.user = user self.session = session @@ -52,7 +52,7 @@ class UserPreCreate(RhodeCodeIntegration display_name = lazy_ugettext('user pre create') def __init__(self, user_data): - super(UserPreCreate, self).__init__() + super().__init__() self.user_data = user_data @@ -66,7 +66,7 @@ class UserPostCreate(RhodeCodeIntegratio display_name = lazy_ugettext('user post create') def __init__(self, user_data): - super(UserPostCreate, self).__init__() + super().__init__() self.user_data = user_data @@ -80,7 +80,7 @@ class UserPreUpdate(RhodeCodeIntegration display_name = lazy_ugettext('user pre update') def __init__(self, user, user_data): - super(UserPreUpdate, self).__init__() + super().__init__() self.user = user self.user_data = user_data @@ -100,5 +100,5 @@ class UserPermissionsChange(RhodecodeEve display_name = lazy_ugettext('user permissions change') def __init__(self, user_ids): - super(UserPermissionsChange, self).__init__() + super().__init__() self.user_ids = user_ids diff --git a/rhodecode/forms/__init__.py b/rhodecode/forms/__init__.py --- a/rhodecode/forms/__init__.py +++ b/rhodecode/forms/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/__init__.py b/rhodecode/integrations/__init__.py --- a/rhodecode/integrations/__init__.py +++ b/rhodecode/integrations/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/registry.py b/rhodecode/integrations/registry.py --- a/rhodecode/integrations/registry.py +++ b/rhodecode/integrations/registry.py @@ -1,4 +1,3 @@ - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/routes.py b/rhodecode/integrations/routes.py --- a/rhodecode/integrations/routes.py +++ b/rhodecode/integrations/routes.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/schema.py b/rhodecode/integrations/schema.py --- a/rhodecode/integrations/schema.py +++ b/rhodecode/integrations/schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/tests/__init__.py b/rhodecode/integrations/tests/__init__.py --- a/rhodecode/integrations/tests/__init__.py +++ b/rhodecode/integrations/tests/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/tests/test_integrations.py b/rhodecode/integrations/tests/test_integrations.py --- a/rhodecode/integrations/tests/test_integrations.py +++ b/rhodecode/integrations/tests/test_integrations.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/types/__init__.py b/rhodecode/integrations/types/__init__.py --- a/rhodecode/integrations/types/__init__.py +++ b/rhodecode/integrations/types/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/types/base.py b/rhodecode/integrations/types/base.py --- a/rhodecode/integrations/types/base.py +++ b/rhodecode/integrations/types/base.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -43,7 +41,7 @@ class UrlTmpl(string.Template): def safe_substitute(self, **kws): # url encode the kw for usage in url kws = {k: urllib.parse.quote(safe_str(v)) for k, v in kws.items()} - return super(UrlTmpl, self).safe_substitute(**kws) + return super().safe_substitute(**kws) class IntegrationTypeBase(object): @@ -265,7 +263,7 @@ class WebhookDataHandler(CommitParsingDa extra_vars = {} for extra_key, extra_val in data['repo']['extra_fields'].items(): - extra_vars['extra__{}'.format(extra_key)] = extra_val + extra_vars[f'extra__{extra_key}'] = extra_val common_vars.update(extra_vars) template_url = self.template_url.replace('${extra:', '${extra__') @@ -388,7 +386,7 @@ class WebhookDataHandler(CommitParsingDa return self.pull_request_event_handler(event, data) else: raise ValueError( - 'event type `{}` has no handler defined'.format(event.__class__)) + f'event type `{event.__class__}` has no handler defined') def get_auth(settings): @@ -408,7 +406,7 @@ def get_url_vars(url_vars): items = [] for section, section_items in url_vars: - items.append('\n*{}*'.format(section)) + items.append(f'\n*{section}*') for key, explanation in section_items: items.append(' {} - {}'.format('${' + key + '}', explanation)) return '\n'.join(items) diff --git a/rhodecode/integrations/types/email.py b/rhodecode/integrations/types/email.py --- a/rhodecode/integrations/types/email.py +++ b/rhodecode/integrations/types/email.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/types/hipchat.py b/rhodecode/integrations/types/hipchat.py --- a/rhodecode/integrations/types/hipchat.py +++ b/rhodecode/integrations/types/hipchat.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -128,7 +126,7 @@ class HipchatIntegrationType(Integration data = event.as_dict() - text = '%s caused a %s event' % ( + text = '{} caused a {} event'.format( data['actor']['username'], event.name) if isinstance(event, events.PullRequestCommentEvent): diff --git a/rhodecode/integrations/types/slack.py b/rhodecode/integrations/types/slack.py --- a/rhodecode/integrations/types/slack.py +++ b/rhodecode/integrations/types/slack.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/integrations/types/webhook.py b/rhodecode/integrations/types/webhook.py --- a/rhodecode/integrations/types/webhook.py +++ b/rhodecode/integrations/types/webhook.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -235,7 +233,7 @@ def post_to_webhook(url_calls, settings) """ call_headers = { - 'User-Agent': 'RhodeCode-webhook-caller/{}'.format(rhodecode.__version__) + 'User-Agent': f'RhodeCode-webhook-caller/{rhodecode.__version__}' } # updated below with custom ones, allows override auth = get_auth(settings) diff --git a/rhodecode/integrations/views.py b/rhodecode/integrations/views.py --- a/rhodecode/integrations/views.py +++ b/rhodecode/integrations/views.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -48,7 +46,7 @@ class IntegrationSettingsViewBase(BaseAp """ def __init__(self, context, request): - super(IntegrationSettingsViewBase, self).__init__(context, request) + super().__init__(context, request) self._load_view_context() def _load_view_context(self): @@ -112,7 +110,7 @@ class IntegrationSettingsViewBase(BaseAp def _get_local_tmpl_context(self, include_app_defaults=True): _ = self.request.translate - c = super(IntegrationSettingsViewBase, self)._get_local_tmpl_context( + c = super()._get_local_tmpl_context( include_app_defaults=include_app_defaults) c.active = 'integrations' diff --git a/rhodecode/lib/__init__.py b/rhodecode/lib/__init__.py --- a/rhodecode/lib/__init__.py +++ b/rhodecode/lib/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/_vendor/__init__.py b/rhodecode/lib/_vendor/__init__.py --- a/rhodecode/lib/_vendor/__init__.py +++ b/rhodecode/lib/_vendor/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/_vendor/authomatic/__init__.py b/rhodecode/lib/_vendor/authomatic/__init__.py --- a/rhodecode/lib/_vendor/authomatic/__init__.py +++ b/rhodecode/lib/_vendor/authomatic/__init__.py @@ -1,4 +1,3 @@ - """ Helper functions for use with :class:`Authomatic`. diff --git a/rhodecode/lib/action_parser.py b/rhodecode/lib/action_parser.py --- a/rhodecode/lib/action_parser.py +++ b/rhodecode/lib/action_parser.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/audit_logger.py b/rhodecode/lib/audit_logger.py --- a/rhodecode/lib/audit_logger.py +++ b/rhodecode/lib/audit_logger.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2017-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -220,7 +218,7 @@ def store(action, user, action_data=None action_spec = ACTIONS.get(action, None) if action_spec is None: - raise ValueError('Action `{}` is not supported'.format(action)) + raise ValueError(f'Action `{action}` is not supported') if not sa_session: sa_session = meta.Session() diff --git a/rhodecode/lib/auth.py b/rhodecode/lib/auth.py --- a/rhodecode/lib/auth.py +++ b/rhodecode/lib/auth.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -208,7 +207,7 @@ class BasicAuth(AuthBasicAuthenticator): def __init__(self, realm, authfunc, registry, auth_http_code=None, initial_call_detection=False, acl_repo_name=None, rc_realm=''): - super(BasicAuth, self).__init__(realm=realm, authfunc=authfunc) + super().__init__(realm=realm, authfunc=authfunc) self.realm = realm self.rc_realm = rc_realm self.initial_call = initial_call_detection diff --git a/rhodecode/lib/caching_query.py b/rhodecode/lib/caching_query.py --- a/rhodecode/lib/caching_query.py +++ b/rhodecode/lib/caching_query.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/celerylib/__init__.py b/rhodecode/lib/celerylib/__init__.py --- a/rhodecode/lib/celerylib/__init__.py +++ b/rhodecode/lib/celerylib/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -84,7 +83,7 @@ def run_task(task, *args, **kwargs): if statsd: task_repr = getattr(task, 'name', task) statsd.incr('rhodecode_celery_task_total', tags=[ - 'task:{}'.format(task_repr), + f'task:{task_repr}', 'mode:sync' ]) diff --git a/rhodecode/lib/celerylib/scheduler.py b/rhodecode/lib/celerylib/scheduler.py --- a/rhodecode/lib/celerylib/scheduler.py +++ b/rhodecode/lib/celerylib/scheduler.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -35,7 +34,7 @@ class FileScheduleEntry(CeleryScheduleEn # because our custom loader passes in some variables that the original # function doesn't expect, we have this thin wrapper - super(FileScheduleEntry, self).__init__( + super().__init__( name=name, task=task, last_run_at=last_run_at, total_run_count=total_run_count, schedule=schedule, args=args, kwargs=kwargs, options=options, relative=relative, app=app) @@ -47,7 +46,7 @@ class FileScheduler(PersistentScheduler) def setup_schedule(self): log.info("setup_schedule called") - super(FileScheduler, self).setup_schedule() + super().setup_schedule() try: diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/celerylib/utils.py b/rhodecode/lib/celerylib/utils.py --- a/rhodecode/lib/celerylib/utils.py +++ b/rhodecode/lib/celerylib/utils.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/channelstream.py b/rhodecode/lib/channelstream.py --- a/rhodecode/lib/channelstream.py +++ b/rhodecode/lib/channelstream.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -286,7 +284,7 @@ def _reload_link(label): def pr_channel(pull_request): repo_name = pull_request.target_repo.repo_name pull_request_id = pull_request.pull_request_id - channel = '/repo${}$/pr/{}'.format(repo_name, pull_request_id) + channel = f'/repo${repo_name}$/pr/{pull_request_id}' log.debug('Getting pull-request channelstream broadcast channel: %s', channel) return channel diff --git a/rhodecode/lib/codeblocks.py b/rhodecode/lib/codeblocks.py --- a/rhodecode/lib/codeblocks.py +++ b/rhodecode/lib/codeblocks.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2011-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -785,8 +783,7 @@ class DiffSet(object): for line in lines: if buf and not line.original or line.original.action == ' ': - for b in buf: - yield b + yield from buf buf = [] if line.original: @@ -813,7 +810,6 @@ class DiffSet(object): line.modified.action, line.modified.content, line.modified.get_comment_args) - for b in buf: - yield b + yield from buf return generator() diff --git a/rhodecode/lib/colander_utils.py b/rhodecode/lib/colander_utils.py --- a/rhodecode/lib/colander_utils.py +++ b/rhodecode/lib/colander_utils.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/colored_formatter.py b/rhodecode/lib/colored_formatter.py --- a/rhodecode/lib/colored_formatter.py +++ b/rhodecode/lib/colored_formatter.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/datelib.py b/rhodecode/lib/datelib.py --- a/rhodecode/lib/datelib.py +++ b/rhodecode/lib/datelib.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/db_manage.py b/rhodecode/lib/db_manage.py --- a/rhodecode/lib/db_manage.py +++ b/rhodecode/lib/db_manage.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/diffs.py b/rhodecode/lib/diffs.py --- a/rhodecode/lib/diffs.py +++ b/rhodecode/lib/diffs.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2011-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -121,8 +119,7 @@ class LimitedDiffContainer(object): return self.diff.__getitem__(key) def __iter__(self): - for l in self.diff: - yield l + yield from self.diff class Action(object): diff --git a/rhodecode/lib/encrypt.py b/rhodecode/lib/encrypt.py --- a/rhodecode/lib/encrypt.py +++ b/rhodecode/lib/encrypt.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -42,7 +40,7 @@ class InvalidDecryptedValue(str): And represent a safe indicator that encryption key is broken """ - content = '<{}({}...)>'.format(cls.__name__, content[:16]) + content = f'<{cls.__name__}({content[:16]}...)>' return str.__new__(cls, content) KEY_FORMAT = b'enc$aes_hmac${1}' diff --git a/rhodecode/lib/encrypt2.py b/rhodecode/lib/encrypt2.py --- a/rhodecode/lib/encrypt2.py +++ b/rhodecode/lib/encrypt2.py @@ -17,7 +17,7 @@ class InvalidDecryptedValue(str): And represent a safe indicator that encryption key is broken """ - content = '<{}({}...)>'.format(cls.__name__, content[:16]) + content = f'<{cls.__name__}({content[:16]}...)>' return str.__new__(cls, content) diff --git a/rhodecode/lib/exc_tracking.py b/rhodecode/lib/exc_tracking.py --- a/rhodecode/lib/exc_tracking.py +++ b/rhodecode/lib/exc_tracking.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -183,10 +182,10 @@ def store_exception(exc_id, exc_info, pr def _find_exc_file(exc_id, prefix=global_prefix): exc_store_path = get_exc_store() if prefix: - exc_id = '{}_{}'.format(exc_id, prefix) + exc_id = f'{exc_id}_{prefix}' else: # search without a prefix - exc_id = '{}'.format(exc_id) + exc_id = f'{exc_id}' found_exc_id = None matches = glob.glob(os.path.join(exc_store_path, exc_id) + '*') diff --git a/rhodecode/lib/exceptions.py b/rhodecode/lib/exceptions.py --- a/rhodecode/lib/exceptions.py +++ b/rhodecode/lib/exceptions.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -95,7 +94,7 @@ class HTTPRequirementError(HTTPClientErr def __init__(self, message, *args, **kwargs): self.title = self.explanation = message - super(HTTPRequirementError, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.args = (message, ) @@ -114,7 +113,7 @@ class HTTPLockedRC(HTTPClientError): self.code = rhodecode.ConfigGet().get_int('lock_ret_code', missing=self.code) self.title = self.explanation = message - super(HTTPLockedRC, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.args = (message, ) @@ -129,7 +128,7 @@ class HTTPBranchProtected(HTTPClientErro def __init__(self, message, *args, **kwargs): self.title = self.explanation = message - super(HTTPBranchProtected, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.args = (message, ) @@ -163,7 +162,7 @@ class VCSServerUnavailable(HTTPBadGatewa self.explanation = 'Could not connect to VCS Server' if message: self.explanation += ': ' + message - super(VCSServerUnavailable, self).__init__() + super().__init__() class ArtifactMetadataDuplicate(ValueError): @@ -171,7 +170,7 @@ class ArtifactMetadataDuplicate(ValueErr def __init__(self, *args, **kwargs): self.err_section = kwargs.pop('err_section', None) self.err_key = kwargs.pop('err_key', None) - super(ArtifactMetadataDuplicate, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class ArtifactMetadataBadValueType(ValueError): diff --git a/rhodecode/lib/ext_json_renderer.py b/rhodecode/lib/ext_json_renderer.py --- a/rhodecode/lib/ext_json_renderer.py +++ b/rhodecode/lib/ext_json_renderer.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/feedgenerator/__init__.py b/rhodecode/lib/feedgenerator/__init__.py --- a/rhodecode/lib/feedgenerator/__init__.py +++ b/rhodecode/lib/feedgenerator/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/feedgenerator/utils.py b/rhodecode/lib/feedgenerator/utils.py --- a/rhodecode/lib/feedgenerator/utils.py +++ b/rhodecode/lib/feedgenerator/utils.py @@ -23,8 +23,8 @@ class SimplerXMLGenerator(XMLGenerator): self._write('<' + name) # sort attributes for consistent output for (name, value) in sorted(attrs.items()): - self._write(' %s=%s' % (name, quoteattr(value))) - self._write(six.u('>')) + self._write(' {}={}'.format(name, quoteattr(value))) + self._write('>') def iri_to_uri(iri): diff --git a/rhodecode/lib/graphmod.py b/rhodecode/lib/graphmod.py --- a/rhodecode/lib/graphmod.py +++ b/rhodecode/lib/graphmod.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -31,7 +30,7 @@ def grandparent(parent_idx_func, lowest_ Return all ancestors of head in roots which commit is greater or equal to lowest_idx. """ - pending = set([head]) + pending = {head} seen = set() kept = set() llowestrev = max(nullrev, lowest_idx) diff --git a/rhodecode/lib/hash_utils.py b/rhodecode/lib/hash_utils.py --- a/rhodecode/lib/hash_utils.py +++ b/rhodecode/lib/hash_utils.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2011-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -123,7 +122,7 @@ def asset(path, ver=None, **kwargs): if ver: query = {'ver': ver} return request.static_path( - 'rhodecode:public/{}'.format(path), _query=query) + f'rhodecode:public/{path}', _query=query) default_html_escape_table = { diff --git a/rhodecode/lib/hooks_base.py b/rhodecode/lib/hooks_base.py --- a/rhodecode/lib/hooks_base.py +++ b/rhodecode/lib/hooks_base.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2013-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -220,7 +218,7 @@ def post_pull(extras): statsd = StatsdClient.statsd if statsd: statsd.incr('rhodecode_pull_total', tags=[ - 'user-agent:{}'.format(user_agent_normalizer(extras.user_agent)), + f'user-agent:{user_agent_normalizer(extras.user_agent)}', ]) output = '' # make lock is a tri state False, True, None. We only make lock on True @@ -229,7 +227,7 @@ def post_pull(extras): Repository.lock(Repository.get_by_repo_name(extras.repository), user.user_id, lock_reason=Repository.LOCK_PULL) - msg = 'Made lock on repo `%s`' % (extras.repository,) + msg = 'Made lock on repo `{}`'.format(extras.repository) output += msg if extras.locked_by[0]: @@ -270,7 +268,7 @@ def post_push(extras): statsd = StatsdClient.statsd if statsd: statsd.incr('rhodecode_push_total', tags=[ - 'user-agent:{}'.format(user_agent_normalizer(extras.user_agent)), + f'user-agent:{user_agent_normalizer(extras.user_agent)}', ]) # Propagate to external components. diff --git a/rhodecode/lib/hooks_daemon.py b/rhodecode/lib/hooks_daemon.py --- a/rhodecode/lib/hooks_daemon.py +++ b/rhodecode/lib/hooks_daemon.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/hooks_utils.py b/rhodecode/lib/hooks_utils.py --- a/rhodecode/lib/hooks_utils.py +++ b/rhodecode/lib/hooks_utils.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/html_filters.py b/rhodecode/lib/html_filters.py --- a/rhodecode/lib/html_filters.py +++ b/rhodecode/lib/html_filters.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2020-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/index/__init__.py b/rhodecode/lib/index/__init__.py --- a/rhodecode/lib/index/__init__.py +++ b/rhodecode/lib/index/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2012-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/settings.py b/rhodecode/model/settings.py --- a/rhodecode/model/settings.py +++ b/rhodecode/model/settings.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -50,8 +49,8 @@ SOCIAL_PLUGINS_LIST = ['github', 'bitbuc class SettingNotFound(Exception): def __init__(self, setting_id): - msg = 'Setting `{}` is not found'.format(setting_id) - super(SettingNotFound, self).__init__(msg) + msg = f'Setting `{setting_id}` is not found' + super().__init__(msg) class SettingsModel(BaseModel): @@ -67,7 +66,7 @@ class SettingsModel(BaseModel): self.UiDbModel = RepoRhodeCodeUi if repo else RhodeCodeUi self.SettingsDbModel = ( RepoRhodeCodeSetting if repo else RhodeCodeSetting) - super(SettingsModel, self).__init__(sa) + super().__init__(sa) def get_ui_by_key(self, key): q = self.UiDbModel.query() @@ -362,7 +361,7 @@ class IssueTrackerSettingsModel(object): Session().add(settings) def _get_keyname(self, key, uid, prefix=''): - return '{0}{1}{2}_{3}'.format( + return '{}{}{}_{}'.format( prefix, self.SETTINGS_PREFIX, key, uid) def _make_dict_for_settings(self, qs): @@ -585,7 +584,7 @@ class VcsSettingsModel(object): data_key = self._get_form_ui_key(section, key) if data_key not in data: raise ValueError( - 'The given data does not contain {} key'.format(data_key)) + f'The given data does not contain {data_key} key') active = data.get(data_key) repo_setting = self.repo_settings.get_ui_by_section_and_key( @@ -604,7 +603,7 @@ class VcsSettingsModel(object): data_key = self._get_form_ui_key(section, key) if data_key not in data: raise ValueError( - 'The given data does not contain {} key'.format(data_key)) + f'The given data does not contain {data_key} key') active = data.get(data_key) repo_setting = self.global_settings.get_ui_by_section_and_key( section, key) @@ -825,7 +824,7 @@ class VcsSettingsModel(object): return keep def _filter_general_settings(self, settings): - keys = ['rhodecode_{}'.format(key) for key in self.GENERAL_SETTINGS] + keys = [f'rhodecode_{key}' for key in self.GENERAL_SETTINGS] return { k: settings[k] for k in settings if k in keys} @@ -849,7 +848,7 @@ class VcsSettingsModel(object): for name in self.GENERAL_SETTINGS: setting = settings.get_setting_by_name(name) if setting: - result_key = 'rhodecode_{}'.format(name) + result_key = f'rhodecode_{name}' result[result_key] = setting.app_settings_value return result @@ -883,10 +882,10 @@ class VcsSettingsModel(object): def _create_or_update_general_settings(self, settings, data): for name in self.GENERAL_SETTINGS: - data_key = 'rhodecode_{}'.format(name) + data_key = f'rhodecode_{name}' if data_key not in data: raise ValueError( - 'The given data does not contain {} key'.format(data_key)) + f'The given data does not contain {data_key} key') setting = settings.create_or_update_setting( name, data[data_key], 'bool') Session().add(setting) @@ -896,7 +895,7 @@ class VcsSettingsModel(object): for data_key in data_keys: if data_key not in data: raise ValueError( - 'The given data does not contain {} key'.format(data_key)) + f'The given data does not contain {data_key} key') return data_keys def create_largeobjects_dirs_if_needed(self, repo_store_path): diff --git a/rhodecode/model/ssh_key.py b/rhodecode/model/ssh_key.py --- a/rhodecode/model/ssh_key.py +++ b/rhodecode/model/ssh_key.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2013-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/update.py b/rhodecode/model/update.py --- a/rhodecode/model/update.py +++ b/rhodecode/model/update.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2013-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/user.py b/rhodecode/model/user.py --- a/rhodecode/model/user.py +++ b/rhodecode/model/user.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -577,8 +576,8 @@ class UserModel(BaseModel): try: if user.username == User.DEFAULT_USER: raise DefaultUserException( - u"You can't remove this user since it's" - u" crucial for entire application") + "You can't remove this user since it's" + " crucial for entire application") handle_user = handle_new_owner or self.cls.get_first_super_admin() log.debug('New detached objects owner %s', handle_user) @@ -587,8 +586,8 @@ class UserModel(BaseModel): if left_overs and user.repositories: repos = [x.repo_name for x in user.repositories] raise UserOwnsReposException( - u'user "%(username)s" still owns %(len_repos)s repositories and cannot be ' - u'removed. Switch owners or remove those repositories:%(list_repos)s' + 'user "%(username)s" still owns %(len_repos)s repositories and cannot be ' + 'removed. Switch owners or remove those repositories:%(list_repos)s' % {'username': user.username, 'len_repos': len(repos), 'list_repos': ', '.join(repos)}) @@ -597,8 +596,8 @@ class UserModel(BaseModel): if left_overs and user.repository_groups: repo_groups = [x.group_name for x in user.repository_groups] raise UserOwnsRepoGroupsException( - u'user "%(username)s" still owns %(len_repo_groups)s repository groups and cannot be ' - u'removed. Switch owners or remove those repository groups:%(list_repo_groups)s' + 'user "%(username)s" still owns %(len_repo_groups)s repository groups and cannot be ' + 'removed. Switch owners or remove those repository groups:%(list_repo_groups)s' % {'username': user.username, 'len_repo_groups': len(repo_groups), 'list_repo_groups': ', '.join(repo_groups)}) @@ -607,17 +606,17 @@ class UserModel(BaseModel): if left_overs and user.user_groups: user_groups = [x.users_group_name for x in user.user_groups] raise UserOwnsUserGroupsException( - u'user "%s" still owns %s user groups and cannot be ' - u'removed. Switch owners or remove those user groups:%s' + 'user "%s" still owns %s user groups and cannot be ' + 'removed. Switch owners or remove those user groups:%s' % (user.username, len(user_groups), ', '.join(user_groups))) left_overs = self._handle_user_pull_requests( user.username, user.user_pull_requests, handle_user, handle_pull_requests) if left_overs and user.user_pull_requests: - pull_requests = ['!{}'.format(x.pull_request_id) for x in user.user_pull_requests] + pull_requests = [f'!{x.pull_request_id}' for x in user.user_pull_requests] raise UserOwnsPullRequestsException( - u'user "%s" still owns %s pull requests and cannot be ' - u'removed. Switch owners or remove those pull requests:%s' + 'user "%s" still owns %s pull requests and cannot be ' + 'removed. Switch owners or remove those pull requests:%s' % (user.username, len(pull_requests), ', '.join(pull_requests))) left_overs = self._handle_user_artifacts( @@ -625,8 +624,8 @@ class UserModel(BaseModel): if left_overs and user.artifacts: artifacts = [x.file_uid for x in user.artifacts] raise UserOwnsArtifactsException( - u'user "%s" still owns %s artifacts and cannot be ' - u'removed. Switch owners or remove those artifacts:%s' + 'user "%s" still owns %s artifacts and cannot be ' + 'removed. Switch owners or remove those artifacts:%s' % (user.username, len(artifacts), ', '.join(artifacts))) user_data = user.get_dict() # fetch user data before expire @@ -941,7 +940,7 @@ class UserModel(BaseModel): auth_token_role = AuthTokenModel.cls - def add_auth_token(self, user, lifetime_minutes, role, description=u'', + def add_auth_token(self, user, lifetime_minutes, role, description='', scope_callback=None): """ Add AuthToken for user. diff --git a/rhodecode/model/user_group.py b/rhodecode/model/user_group.py --- a/rhodecode/model/user_group.py +++ b/rhodecode/model/user_group.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2011-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -298,7 +296,7 @@ class UserGroupModel(BaseModel): assigned_to_repo+assigned_to_repo_group)) raise UserGroupAssignedException( - 'UserGroup assigned to %s' % (assigned,)) + 'UserGroup assigned to {}'.format(assigned)) self.sa.delete(user_group) except Exception: log.error(traceback.format_exc()) @@ -710,7 +708,7 @@ class UserGroupModel(BaseModel): query = query.filter(UserGroup.users_group_active == true()) if name_contains: - ilike_expression = u'%{}%'.format(safe_str(name_contains)) + ilike_expression = f'%{safe_str(name_contains)}%' query = query.filter( UserGroup.users_group_name.ilike(ilike_expression))\ .order_by(func.length(UserGroup.users_group_name))\ diff --git a/rhodecode/model/validation_schema/__init__.py b/rhodecode/model/validation_schema/__init__.py --- a/rhodecode/model/validation_schema/__init__.py +++ b/rhodecode/model/validation_schema/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/validation_schema/preparers.py b/rhodecode/model/validation_schema/preparers.py --- a/rhodecode/model/validation_schema/preparers.py +++ b/rhodecode/model/validation_schema/preparers.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/validation_schema/schemas/__init__.py b/rhodecode/model/validation_schema/schemas/__init__.py --- a/rhodecode/model/validation_schema/schemas/__init__.py +++ b/rhodecode/model/validation_schema/schemas/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/validation_schema/schemas/comment_schema.py b/rhodecode/model/validation_schema/schemas/comment_schema.py --- a/rhodecode/model/validation_schema/schemas/comment_schema.py +++ b/rhodecode/model/validation_schema/schemas/comment_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2017-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -39,13 +37,13 @@ def unique_gist_validator(node, value): from rhodecode.model.db import Gist existing = Gist.get_by_access_id(value) if existing: - msg = _(u'Gist with name {} already exists').format(value) + msg = _('Gist with name {} already exists').format(value) raise colander.Invalid(node, msg) def filename_validator(node, value): if value != os.path.basename(value): - msg = _(u'Filename {} cannot be inside a directory').format(value) + msg = _('Filename {} cannot be inside a directory').format(value) raise colander.Invalid(node, msg) diff --git a/rhodecode/model/validation_schema/schemas/gist_schema.py b/rhodecode/model/validation_schema/schemas/gist_schema.py --- a/rhodecode/model/validation_schema/schemas/gist_schema.py +++ b/rhodecode/model/validation_schema/schemas/gist_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -54,7 +52,7 @@ def nodes_to_sequence(nodes, colander_no def sequence_to_nodes(nodes, colander_node=None): if not isinstance(nodes, list): - msg = 'Nodes needs to be a list, got {}'.format(type(nodes)) + msg = f'Nodes needs to be a list, got {type(nodes)}' raise colander.Invalid(colander_node, msg) nodes = Nodes().deserialize(nodes) @@ -71,7 +69,7 @@ def sequence_to_nodes(nodes, colander_no out[filename].update(file_data_skip) except Exception as e: - msg = 'Invalid data format org_exc:`{}`'.format(repr(e)) + msg = f'Invalid data format org_exc:`{repr(e)}`' raise colander.Invalid(colander_node, msg) return out diff --git a/rhodecode/model/validation_schema/schemas/integration_schema.py b/rhodecode/model/validation_schema/schemas/integration_schema.py --- a/rhodecode/model/validation_schema/schemas/integration_schema.py +++ b/rhodecode/model/validation_schema/schemas/integration_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/validation_schema/schemas/repo_group_schema.py b/rhodecode/model/validation_schema/schemas/repo_group_schema.py --- a/rhodecode/model/validation_schema/schemas/repo_group_schema.py +++ b/rhodecode/model/validation_schema/schemas/repo_group_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -50,15 +48,15 @@ def deferred_can_write_to_group_validato messages = { 'invalid_parent_repo_group': - _(u"Parent repository group `{}` does not exist"), + _("Parent repository group `{}` does not exist"), # permissions denied we expose as not existing, to prevent # resource discovery 'permission_denied_parent_group': - _(u"You do not have the permissions to store " - u"repository groups inside repository group `{}`"), + _("You do not have the permissions to store " + "repository groups inside repository group `{}`"), 'permission_denied_root': - _(u"You do not have the permission to store " - u"repository groups in the root location.") + _("You do not have the permission to store " + "repository groups in the root location.") } value = value['repo_group_name'] @@ -124,7 +122,7 @@ def deferred_repo_group_owner_validator( value = username_converter(value) existing = User.get_by_username(value) if not existing: - msg = _(u'Repo group owner with id `{}` does not exists').format( + msg = _('Repo group owner with id `{}` does not exists').format( value) raise colander.Invalid(node, msg) @@ -142,12 +140,12 @@ def deferred_unique_name_validator(node, existing = Repository.get_by_repo_name(value) if name_changed and existing: - msg = _(u'Repository with name `{}` already exists').format(value) + msg = _('Repository with name `{}` already exists').format(value) raise colander.Invalid(node, msg) existing_group = RepoGroup.get_by_group_name(value) if name_changed and existing_group: - msg = _(u'Repository group with name `{}` already exists').format( + msg = _('Repository group with name `{}` already exists').format( value) raise colander.Invalid(node, msg) return unique_name_validator @@ -184,7 +182,7 @@ class GroupType(colander.Mapping): if cstruct is colander.null: return cstruct - appstruct = super(GroupType, self).deserialize(node, cstruct) + appstruct = super().deserialize(node, cstruct) validated_name = appstruct['repo_group_name'] # inject group based on once deserialized data @@ -253,7 +251,7 @@ class RepoGroupSchema(colander.Schema): permissions, and as last step uniqueness """ - appstruct = super(RepoGroupSchema, self).deserialize(cstruct) + appstruct = super().deserialize(cstruct) validated_name = appstruct['repo_group_name'] # second pass to validate permissions to repo_group diff --git a/rhodecode/model/validation_schema/schemas/repo_schema.py b/rhodecode/model/validation_schema/schemas/repo_schema.py --- a/rhodecode/model/validation_schema/schemas/repo_schema.py +++ b/rhodecode/model/validation_schema/schemas/repo_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -53,7 +51,7 @@ def deferred_repo_owner_validator(node, value = username_converter(value) existing = User.get_by_username(value) if not existing: - msg = _(u'Repo owner with id `{}` does not exists').format(value) + msg = _('Repo owner with id `{}` does not exists').format(value) raise colander.Invalid(node, msg) return repo_owner_validator @@ -96,11 +94,11 @@ def deferred_fork_of_validator(node, kw) from rhodecode.model.db import Repository, RepoGroup existing = Repository.get_by_repo_name(value) if not existing: - msg = _(u'Fork with id `{}` does not exists').format(value) + msg = _('Fork with id `{}` does not exists').format(value) raise colander.Invalid(node, msg) elif old_values['repo_name'] == existing.repo_name: - msg = _(u'Cannot set fork of ' - u'parameter of this repository to itself').format(value) + msg = _('Cannot set fork of ' + 'parameter of this repository to itself').format(value) raise colander.Invalid(node, msg) return fork_of_validator @@ -124,14 +122,14 @@ def deferred_can_write_to_group_validato messages = { 'invalid_repo_group': - _(u"Repository group `{}` does not exist"), + _("Repository group `{}` does not exist"), # permissions denied we expose as not existing, to prevent # resource discovery 'permission_denied': - _(u"Repository group `{}` does not exist"), + _("Repository group `{}` does not exist"), 'permission_denied_root': - _(u"You do not have the permission to store " - u"repositories in the root location.") + _("You do not have the permission to store " + "repositories in the root location.") } value = value['repo_group_name'] @@ -215,12 +213,12 @@ def deferred_unique_name_validator(node, existing = Repository.get_by_repo_name(value) if name_changed and existing: - msg = _(u'Repository with name `{}` already exists').format(value) + msg = _('Repository with name `{}` already exists').format(value) raise colander.Invalid(node, msg) existing_group = RepoGroup.get_by_group_name(value) if name_changed and existing_group: - msg = _(u'Repository group with name `{}` already exists').format( + msg = _('Repository group with name `{}` already exists').format( value) raise colander.Invalid(node, msg) return unique_name_validator @@ -271,7 +269,7 @@ class GroupType(colander.Mapping): if cstruct is colander.null: return cstruct - appstruct = super(GroupType, self).deserialize(node, cstruct) + appstruct = super().deserialize(node, cstruct) validated_name = appstruct['repo_group_name'] # inject group based on once deserialized data @@ -380,7 +378,7 @@ class RepoSchema(colander.MappingSchema) """ # first pass, to validate given data - appstruct = super(RepoSchema, self).deserialize(cstruct) + appstruct = super().deserialize(cstruct) validated_name = appstruct['repo_name'] # second pass to validate permissions to repo_group diff --git a/rhodecode/model/validation_schema/schemas/reviewer_schema.py b/rhodecode/model/validation_schema/schemas/reviewer_schema.py --- a/rhodecode/model/validation_schema/schemas/reviewer_schema.py +++ b/rhodecode/model/validation_schema/schemas/reviewer_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/validation_schema/schemas/search_schema.py b/rhodecode/model/validation_schema/schemas/search_schema.py --- a/rhodecode/model/validation_schema/schemas/search_schema.py +++ b/rhodecode/model/validation_schema/schemas/search_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -30,7 +28,7 @@ def sort_validator(node, value): if value.startswith('desc:'): return value - msg = u'Invalid search sort, must be `oldfirst`, `newfirst`, or start with asc: or desc:' + msg = 'Invalid search sort, must be `oldfirst`, `newfirst`, or start with asc: or desc:' raise colander.Invalid(node, msg) diff --git a/rhodecode/model/validation_schema/schemas/user_group_schema.py b/rhodecode/model/validation_schema/schemas/user_group_schema.py --- a/rhodecode/model/validation_schema/schemas/user_group_schema.py +++ b/rhodecode/model/validation_schema/schemas/user_group_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -47,7 +45,7 @@ def deferred_user_group_owner_validator( value = username_converter(value) existing = User.get_by_username(value) if not existing: - msg = _(u'User group owner with id `{}` does not exists').format(value) + msg = _('User group owner with id `{}` does not exists').format(value) raise colander.Invalid(node, msg) return owner_validator @@ -76,5 +74,5 @@ class UserGroupSchema(colander.Schema): permissions, and as last step uniqueness """ - appstruct = super(UserGroupSchema, self).deserialize(cstruct) + appstruct = super().deserialize(cstruct) return appstruct diff --git a/rhodecode/model/validation_schema/schemas/user_schema.py b/rhodecode/model/validation_schema/schemas/user_schema.py --- a/rhodecode/model/validation_schema/schemas/user_schema.py +++ b/rhodecode/model/validation_schema/schemas/user_schema.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -69,9 +67,9 @@ def deferred_username_validator(node, kw def name_validator(node, value): msg = _( - u'Username may only contain alphanumeric characters ' - u'underscores, periods or dashes and must begin with ' - u'alphanumeric character or underscore') + 'Username may only contain alphanumeric characters ' + 'underscores, periods or dashes and must begin with ' + 'alphanumeric character or underscore') if not re.match(r'^[\w]{1}[\w\-\.]{0,254}$', value): raise colander.Invalid(node, msg) @@ -126,7 +124,7 @@ class UserSchema(colander.Schema): permissions, and as last step uniqueness """ - appstruct = super(UserSchema, self).deserialize(cstruct) + appstruct = super().deserialize(cstruct) return appstruct @@ -145,7 +143,7 @@ def deferred_additional_email_validator( raise colander.Invalid(node, msg) user = User.get_by_email(value, case_insensitive=True) if user: - msg = _(u'This e-mail address is already taken') + msg = _('This e-mail address is already taken') raise colander.Invalid(node, msg) c = colander.Email() return c(node, value) diff --git a/rhodecode/model/validation_schema/types.py b/rhodecode/model/validation_schema/types.py --- a/rhodecode/model/validation_schema/types.py +++ b/rhodecode/model/validation_schema/types.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -62,7 +60,7 @@ class RepoNameType(colander.String): SEPARATOR = '/' def deserialize(self, node, cstruct): - result = super(RepoNameType, self).deserialize(node, cstruct) + result = super().deserialize(node, cstruct) if cstruct is colander.null: return colander.null return self._normalize(result) @@ -78,7 +76,7 @@ class GroupNameType(colander.String): if cstruct is RootLocation: return cstruct - result = super(GroupNameType, self).deserialize(node, cstruct) + result = super().deserialize(node, cstruct) if cstruct is colander.null: return colander.null return self._normalize(result) @@ -116,7 +114,7 @@ class StringBooleanType(colander.String) return False else: raise colander.Invalid( - node, '{} value cannot be translated to bool'.format(value)) + node, f'{value} value cannot be translated to bool') class UserOrUserGroupType(colander.SchemaType): @@ -144,7 +142,7 @@ class UserOrUserGroupType(colander.Schem return appstruct.users_group_name raise colander.Invalid( - node, '%s is not a valid %s' % (appstruct, ' or '.join(self.scopes))) + node, '{} is not a valid {}'.format(appstruct, ' or '.join(self.scopes))) def deserialize(self, node, cstruct): if cstruct is colander.null: @@ -177,7 +175,7 @@ class UserOrUserGroupType(colander.Schem return usergroup raise colander.Invalid( - node, '%s is not a valid %s' % (cstruct, ' or '.join(self.scopes))) + node, '{} is not a valid {}'.format(cstruct, ' or '.join(self.scopes))) class UserType(UserOrUserGroupType): @@ -191,6 +189,6 @@ class UserGroupType(UserOrUserGroupType) class StrOrIntType(colander.String): def deserialize(self, node, cstruct): if isinstance(cstruct, str): - return super(StrOrIntType, self).deserialize(node, cstruct) + return super().deserialize(node, cstruct) else: return colander.Integer().deserialize(node, cstruct) diff --git a/rhodecode/model/validation_schema/utils.py b/rhodecode/model/validation_schema/utils.py --- a/rhodecode/model/validation_schema/utils.py +++ b/rhodecode/model/validation_schema/utils.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/validation_schema/validators.py b/rhodecode/model/validation_schema/validators.py --- a/rhodecode/model/validation_schema/validators.py +++ b/rhodecode/model/validation_schema/validators.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2011-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -120,7 +118,7 @@ def url_validator(url, repo_type, config # no validation for SVN yet return - raise InvalidCloneUrl('Invalid repo type specified: `{}`'.format(repo_type)) + raise InvalidCloneUrl(f'Invalid repo type specified: `{repo_type}`') class CloneUriValidator(object): @@ -157,5 +155,5 @@ def json_validator_with_exc(node, value) try: json.loads(value) except (Exception,) as e: - msg = _('Please enter a valid json object: `{}`'.format(e)) + msg = _(f'Please enter a valid json object: `{e}`') raise colander.Invalid(node, msg) diff --git a/rhodecode/model/validation_schema/widgets.py b/rhodecode/model/validation_schema/widgets.py --- a/rhodecode/model/validation_schema/widgets.py +++ b/rhodecode/model/validation_schema/widgets.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2011-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/model/validators.py b/rhodecode/model/validators.py --- a/rhodecode/model/validators.py +++ b/rhodecode/model/validators.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/subscribers.py b/rhodecode/subscribers.py --- a/rhodecode/subscribers.py +++ b/rhodecode/subscribers.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -370,7 +369,7 @@ class AsyncSubprocessSubscriber(AsyncSub def __init__(self, cmd, timeout=None): if not isinstance(cmd, (list, tuple)): cmd = shlex.split(cmd) - super(AsyncSubprocessSubscriber, self).__init__() + super().__init__() self._cmd = cmd self._timeout = timeout diff --git a/rhodecode/tweens.py b/rhodecode/tweens.py --- a/rhodecode/tweens.py +++ b/rhodecode/tweens.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/typing/__init__.py b/rhodecode/typing/__init__.py --- a/rhodecode/typing/__init__.py +++ b/rhodecode/typing/__init__.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify