diff --git a/rhodecode/lib/vcs/__init__.py b/rhodecode/lib/vcs/__init__.py --- a/rhodecode/lib/vcs/__init__.py +++ b/rhodecode/lib/vcs/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -95,7 +93,7 @@ def connect_vcs(server_and_port, protoco if protocol == 'http': connect_http(server_and_port) else: - raise Exception('Invalid vcs server protocol "{}"'.format(protocol)) + raise Exception(f'Invalid vcs server protocol "{protocol}"') class CurlSession(object): diff --git a/rhodecode/lib/vcs/backends/__init__.py b/rhodecode/lib/vcs/backends/__init__.py --- a/rhodecode/lib/vcs/backends/__init__.py +++ b/rhodecode/lib/vcs/backends/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/base.py b/rhodecode/lib/vcs/backends/base.py --- a/rhodecode/lib/vcs/backends/base.py +++ b/rhodecode/lib/vcs/backends/base.py @@ -247,7 +247,7 @@ class MergeResponse(object): self.metadata = metadata or {} def __repr__(self): - return ''.format(self.label, self.failure_reason) + return f'' def __eq__(self, other): same_instance = isinstance(other, self.__class__) @@ -320,8 +320,8 @@ class BaseRepository(object): """ DEFAULT_BRANCH_NAME = None - DEFAULT_CONTACT = u"Unknown" - DEFAULT_DESCRIPTION = u"unknown" + DEFAULT_CONTACT = "Unknown" + DEFAULT_DESCRIPTION = "unknown" EMPTY_COMMIT_ID = '0' * 40 COMMIT_ID_PAT = re.compile(r'[0-9a-fA-F]{40}') @@ -347,7 +347,7 @@ class BaseRepository(object): raise NotImplementedError def __repr__(self): - return '<%s at %s>' % (self.__class__.__name__, self.path) + return '<{} at {}>'.format(self.__class__.__name__, self.path) def __len__(self): return self.count() @@ -716,7 +716,7 @@ class BaseRepository(object): """ return os.path.join( os.path.dirname(repo_path), - '.__shadow_%s_%s' % (os.path.basename(repo_path), workspace_id)) + '.__shadow_{}_{}'.format(os.path.basename(repo_path), workspace_id)) @classmethod def _get_shadow_repository_path(cls, repo_path, repo_id, workspace_id): @@ -728,7 +728,7 @@ class BaseRepository(object): else: return os.path.join( os.path.dirname(repo_path), - '.__shadow_repo_%s_%s' % (repo_id, workspace_id)) + '.__shadow_repo_{}_{}'.format(repo_id, workspace_id)) def cleanup_merge_workspace(self, repo_id, workspace_id): """ @@ -806,7 +806,7 @@ class BaseRepository(object): def _validate_branch_name(self, branch_name): if branch_name and branch_name not in self.branches_all: - msg = ("Branch %s not found in %s" % (branch_name, self)) + msg = ("Branch {} not found in {}".format(branch_name, self)) raise BranchDoesNotExistError(msg) # @@ -1342,7 +1342,7 @@ class BaseCommit(object): """ Returns total number of bytes from contents of all filenodes. """ - return sum((node.size for node in self.get_filenodes_generator())) + return sum(node.size for node in self.get_filenodes_generator()) def walk(self, topurl=''): """ @@ -1369,16 +1369,14 @@ class BaseCommit(object): for dir_node in top_node.dirs: if has_default_pre_load: dir_node.default_pre_load = default_pre_load - for tup in self.walk(dir_node): - yield tup + yield from self.walk(dir_node) def get_filenodes_generator(self): """ Returns generator that yields *all* file nodes. """ for topnode, dirs, files in self.walk(): - for node in files: - yield node + yield from files # # Utilities for sub classes to support consistent behavior @@ -1426,7 +1424,7 @@ class BaseChangeset(BaseCommit, metaclas def __new__(cls, *args, **kwargs): warnings.warn( "Use BaseCommit instead of BaseChangeset", DeprecationWarning) - return super(BaseChangeset, cls).__new__(cls, *args, **kwargs) + return super().__new__(cls, *args, **kwargs) class BaseInMemoryCommit(object): @@ -1585,7 +1583,7 @@ class BaseInMemoryCommit(object): pass else: raise NodeAlreadyExistsError( - "Node `%s` already exists at %s" % (node.path, p)) + "Node `{}` already exists at {}".format(node.path, p)) # Check nodes marked as changed missing = set(self.changed) @@ -1668,7 +1666,7 @@ class BaseInMemoryChangeset(BaseInMemory def __new__(cls, *args, **kwargs): warnings.warn( "Use BaseCommit instead of BaseInMemoryCommit", DeprecationWarning) - return super(BaseInMemoryChangeset, cls).__new__(cls, *args, **kwargs) + return super().__new__(cls, *args, **kwargs) class EmptyCommit(BaseCommit): @@ -1745,7 +1743,7 @@ class EmptyChangeset(EmptyCommit, metacl warnings.warn( "Parameter requested_revision not supported anymore", DeprecationWarning) - super(EmptyChangeset, self).__init__( + super().__init__( commit_id=cs, repo=repo, alias=alias, idx=revision, message=message, author=author, date=date) @@ -1832,7 +1830,7 @@ class Config(object): return clone def __repr__(self): - return '' % ( + return ''.format( len(self._values), hex(id(self))) def items(self, section): diff --git a/rhodecode/lib/vcs/backends/git/__init__.py b/rhodecode/lib/vcs/backends/git/__init__.py --- a/rhodecode/lib/vcs/backends/git/__init__.py +++ b/rhodecode/lib/vcs/backends/git/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/git/commit.py b/rhodecode/lib/vcs/backends/git/commit.py --- a/rhodecode/lib/vcs/backends/git/commit.py +++ b/rhodecode/lib/vcs/backends/git/commit.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -476,8 +474,7 @@ class GitCommit(base.BaseCommit): # ConfigParser fails if there are whitespaces, also it needs an iterable # file like content def iter_content(_content): - for line in _content.splitlines(): - yield line + yield from _content.splitlines() parser = configparser.RawConfigParser() parser.read_file(iter_content(submodules_node.content)) diff --git a/rhodecode/lib/vcs/backends/git/diff.py b/rhodecode/lib/vcs/backends/git/diff.py --- a/rhodecode/lib/vcs/backends/git/diff.py +++ b/rhodecode/lib/vcs/backends/git/diff.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/git/inmemory.py b/rhodecode/lib/vcs/backends/git/inmemory.py --- a/rhodecode/lib/vcs/backends/git/inmemory.py +++ b/rhodecode/lib/vcs/backends/git/inmemory.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/git/repository.py b/rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py +++ b/rhodecode/lib/vcs/backends/git/repository.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -55,7 +53,7 @@ class GitRepository(BaseRepository): Git repository backend. """ DEFAULT_BRANCH_NAME = os.environ.get('GIT_DEFAULT_BRANCH_NAME') or 'master' - DEFAULT_REF = 'branch:{}'.format(DEFAULT_BRANCH_NAME) + DEFAULT_REF = f'branch:{DEFAULT_BRANCH_NAME}' contact = BaseRepository.DEFAULT_CONTACT @@ -95,8 +93,8 @@ class GitRepository(BaseRepository): return commit_ids def _rebuild_cache(self, commit_ids): - self._commit_ids = dict((commit_id, index) - for index, commit_id in enumerate(commit_ids)) + self._commit_ids = {commit_id: index + for index, commit_id in enumerate(commit_ids)} def run_git_command(self, cmd, **opts): """ @@ -375,7 +373,7 @@ class GitRepository(BaseRepository): if name in self.tags: raise TagAlreadyExistError("Tag %s already exists" % name) commit = self.get_commit(commit_id=commit_id) - message = message or "Added tag %s for commit %s" % (name, commit.raw_id) + message = message or "Added tag {} for commit {}".format(name, commit.raw_id) self._remote.set_refs('refs/tags/%s' % name, commit.raw_id) @@ -421,7 +419,7 @@ class GitRepository(BaseRepository): return tree def get_remote_ref(self, ref_name): - ref_key = 'refs/remotes/origin/{}'.format(safe_str(ref_name)) + ref_key = f'refs/remotes/origin/{safe_str(ref_name)}' try: return self._refs[ref_key] except Exception: @@ -643,7 +641,7 @@ class GitRepository(BaseRepository): else: output, __ = repo1.run_git_command( ['log', '--reverse', '--pretty=format: %H', '-s', - '%s..%s' % (commit_id1, commit_id2)]) + '{}..{}'.format(commit_id1, commit_id2)]) commits = [ repo1.get_commit(commit_id=commit_id, pre_load=pre_load) for commit_id in self.COMMIT_ID_PAT.findall(output)] @@ -797,7 +795,7 @@ class GitRepository(BaseRepository): self.run_git_command(cmd, fail_on_stderr=False) def _local_reset(self, branch_name): - branch_name = '{}'.format(branch_name) + branch_name = f'{branch_name}' cmd = ['reset', '--hard', branch_name, '--'] self.run_git_command(cmd, fail_on_stderr=False) @@ -880,7 +878,7 @@ class GitRepository(BaseRepository): files = self.run_git_command(['diff', '--name-only', '--diff-filter', 'U'], fail_on_stderr=False)[0].splitlines() # NOTE(marcink): we add U notation for consistent with HG backend output - unresolved = ['U {}'.format(f) for f in files] + unresolved = [f'U {f}' for f in files] # Cleanup any merge leftovers self._remote.invalidate_vcs_cache() @@ -914,7 +912,7 @@ class GitRepository(BaseRepository): target_repo._local_pull(self.path, source_branch) else: cmd = ['push', os.path.abspath(repository_path), - '%s:%s' % (source_branch, target_branch)] + '{}:{}'.format(source_branch, target_branch)] gitenv = {} if rc_scm_data: gitenv.update({'RC_SCM_DATA': rc_scm_data}) @@ -924,7 +922,7 @@ class GitRepository(BaseRepository): self.run_git_command(cmd, fail_on_stderr=False, extra_env=gitenv) def _get_new_pr_branch(self, source_branch, target_branch): - prefix = 'pr_%s-%s_' % (source_branch, target_branch) + prefix = 'pr_{}-{}_'.format(source_branch, target_branch) pr_branches = [] for branch in self.branches: if branch.startswith(prefix): diff --git a/rhodecode/lib/vcs/backends/hg/__init__.py b/rhodecode/lib/vcs/backends/hg/__init__.py --- a/rhodecode/lib/vcs/backends/hg/__init__.py +++ b/rhodecode/lib/vcs/backends/hg/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/hg/commit.py b/rhodecode/lib/vcs/backends/hg/commit.py --- a/rhodecode/lib/vcs/backends/hg/commit.py +++ b/rhodecode/lib/vcs/backends/hg/commit.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -291,7 +289,7 @@ class MercurialCommit(base.BaseCommit): if self._get_kind(path) != NodeKind.DIR: raise CommitError( - "Directory does not exist for idx %s at '%s'" % (self.raw_id, path)) + "Directory does not exist for idx {} at '{}'".format(self.raw_id, path)) path = self._fix_path(path) filenodes = [ diff --git a/rhodecode/lib/vcs/backends/hg/diff.py b/rhodecode/lib/vcs/backends/hg/diff.py --- a/rhodecode/lib/vcs/backends/hg/diff.py +++ b/rhodecode/lib/vcs/backends/hg/diff.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/hg/inmemory.py b/rhodecode/lib/vcs/backends/hg/inmemory.py --- a/rhodecode/lib/vcs/backends/hg/inmemory.py +++ b/rhodecode/lib/vcs/backends/hg/inmemory.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/hg/repository.py b/rhodecode/lib/vcs/backends/hg/repository.py --- a/rhodecode/lib/vcs/backends/hg/repository.py +++ b/rhodecode/lib/vcs/backends/hg/repository.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -104,8 +102,8 @@ class MercurialRepository(BaseRepository return commit_ids def _rebuild_cache(self, commit_ids): - self._commit_ids = dict((commit_id, index) - for index, commit_id in enumerate(commit_ids)) + self._commit_ids = {commit_id: index + for index, commit_id in enumerate(commit_ids)} @CachedProperty def branches(self): @@ -180,7 +178,7 @@ class MercurialRepository(BaseRepository local = kwargs.setdefault('local', False) if message is None: - message = "Added tag %s for commit %s" % (name, commit.short_id) + message = "Added tag {} for commit {}".format(name, commit.short_id) date, tz = date_to_timestamp_plus_offset(date) @@ -531,17 +529,17 @@ class MercurialRepository(BaseRepository commit_filter = [] if branch_name and not branch_ancestors: - commit_filter.append('branch("%s")' % (branch_name,)) + commit_filter.append('branch("{}")'.format(branch_name)) elif branch_name and branch_ancestors: - commit_filter.append('ancestors(branch("%s"))' % (branch_name,)) + commit_filter.append('ancestors(branch("{}"))'.format(branch_name)) if start_date and not end_date: - commit_filter.append('date(">%s")' % (start_date,)) + commit_filter.append('date(">{}")'.format(start_date)) if end_date and not start_date: - commit_filter.append('date("<%s")' % (end_date,)) + commit_filter.append('date("<{}")'.format(end_date)) if start_date and end_date: commit_filter.append( - 'date(">%s") and date("<%s")' % (start_date, end_date)) + 'date(">{}") and date("<{}")'.format(start_date, end_date)) if not show_hidden: commit_filter.append('not obsolete()') @@ -659,7 +657,7 @@ class MercurialRepository(BaseRepository unresolved = None if use_rebase: try: - bookmark_name = 'rcbook%s%s' % (source_ref_commit_id, target_ref_commit_id) + bookmark_name = 'rcbook{}{}'.format(source_ref_commit_id, target_ref_commit_id) self.bookmark(bookmark_name, revision=source_ref.commit_id) self._remote.rebase( source=source_ref_commit_id, dest=target_ref_commit_id) @@ -689,7 +687,7 @@ class MercurialRepository(BaseRepository self._remote.invalidate_vcs_cache() self._remote.commit( message=safe_str(merge_message), - username=safe_str('%s <%s>' % (user_name, user_email))) + username=safe_str('{} <{}>'.format(user_name, user_email))) self._remote.invalidate_vcs_cache() return self._identify(), True except RepositoryError as e: @@ -716,11 +714,11 @@ class MercurialRepository(BaseRepository commit needs to be pushed. """ self._update(source_ref.commit_id) - message = close_message or "Closing branch: `{}`".format(source_ref.name) + message = close_message or f"Closing branch: `{source_ref.name}`" try: self._remote.commit( message=safe_str(message), - username=safe_str('%s <%s>' % (user_name, user_email)), + username=safe_str('{} <{}>'.format(user_name, user_email)), close_branch=True) self._remote.invalidate_vcs_cache() return self._identify(), True diff --git a/rhodecode/lib/vcs/backends/svn/__init__.py b/rhodecode/lib/vcs/backends/svn/__init__.py --- a/rhodecode/lib/vcs/backends/svn/__init__.py +++ b/rhodecode/lib/vcs/backends/svn/__init__.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/svn/commit.py b/rhodecode/lib/vcs/backends/svn/commit.py --- a/rhodecode/lib/vcs/backends/svn/commit.py +++ b/rhodecode/lib/vcs/backends/svn/commit.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -55,7 +53,7 @@ class SubversionCommit(base.BaseCommit): # which knows how to translate commit index and commit id self.raw_id = commit_id self.short_id = commit_id - self.id = 'r%s' % (commit_id, ) + self.id = 'r{}'.format(commit_id) # TODO: Implement the following placeholder attributes self.nodes = {} @@ -201,7 +199,7 @@ class SubversionCommit(base.BaseCommit): return nodes.NodeKind.DIR else: raise CommitError( - "Node does not exist at the given path '%s'" % (path, )) + "Node does not exist at the given path '{}'".format(path)) @LazyProperty def _changes_cache(self): diff --git a/rhodecode/lib/vcs/backends/svn/diff.py b/rhodecode/lib/vcs/backends/svn/diff.py --- a/rhodecode/lib/vcs/backends/svn/diff.py +++ b/rhodecode/lib/vcs/backends/svn/diff.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/svn/inmemory.py b/rhodecode/lib/vcs/backends/svn/inmemory.py --- a/rhodecode/lib/vcs/backends/svn/inmemory.py +++ b/rhodecode/lib/vcs/backends/svn/inmemory.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/backends/svn/repository.py b/rhodecode/lib/vcs/backends/svn/repository.py --- a/rhodecode/lib/vcs/backends/svn/repository.py +++ b/rhodecode/lib/vcs/backends/svn/repository.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -223,7 +221,7 @@ class SubversionRepository(base.BaseRepo commit_idx = svn_rev - 1 if commit_idx >= len(self.commit_ids): raise CommitDoesNotExistError( - "Commit at index %s does not exist." % (commit_idx, )) + "Commit at index {} does not exist.".format(commit_idx)) return commit_idx @staticmethod @@ -247,7 +245,7 @@ class SubversionRepository(base.BaseRepo def _check_path(self): if not os.path.exists(self.path): - raise VCSError('Path "%s" does not exist!' % (self.path, )) + raise VCSError('Path "{}" does not exist!'.format(self.path)) if not self._remote.is_path_valid_repository(self.path): raise VCSError( 'Path "%s" does not contain a Subversion repository' % @@ -286,7 +284,7 @@ class SubversionRepository(base.BaseRepo try: commit_id = self.commit_ids[commit_idx] except IndexError: - raise CommitDoesNotExistError('No commit with idx: {}'.format(commit_idx)) + raise CommitDoesNotExistError(f'No commit with idx: {commit_idx}') commit_id = self._sanitize_commit_id(commit_id) commit = SubversionCommit(repository=self, commit_id=commit_id) @@ -343,11 +341,11 @@ class SubversionRepository(base.BaseRepo return commit_id else: raise CommitDoesNotExistError( - "Commit %s does not exist." % (commit_id, )) + "Commit {} does not exist.".format(commit_id)) if commit_id not in [ None, 'HEAD', 'tip', self.DEFAULT_BRANCH_NAME]: raise CommitDoesNotExistError( - "Commit id %s not understood." % (commit_id, )) + "Commit id {} not understood.".format(commit_id)) svn_rev = self._remote.lookup('HEAD') return str(svn_rev) diff --git a/rhodecode/lib/vcs/client_http.py b/rhodecode/lib/vcs/client_http.py --- a/rhodecode/lib/vcs/client_http.py +++ b/rhodecode/lib/vcs/client_http.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2016-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -68,7 +66,7 @@ def _remote_call(url, payload, exception log.warning(f'Received a "Connection reset by peer" error. ' f'Retrying... ({attempt + 1}/{retries})') continue # Retry if connection reset error. - msg = '{}. \npycurl traceback: {}'.format(e, traceback.format_exc()) + msg = f'{e}. \npycurl traceback: {traceback.format_exc()}' raise exceptions.HttpVCSCommunicationError(msg) except Exception as e: message = getattr(e, 'message', '') @@ -130,7 +128,7 @@ def _streaming_remote_call(url, payload, response = session.post(url, data=msgpack.packb(payload), headers=headers) except pycurl.error as e: error_code, error_message = e.args - msg = '{}. \npycurl traceback: {}'.format(e, traceback.format_exc()) + msg = f'{e}. \npycurl traceback: {traceback.format_exc()}' raise exceptions.HttpVCSCommunicationError(msg) except Exception as e: message = getattr(e, 'message', '') @@ -180,7 +178,7 @@ class RemoteVCSMaker(object): @classmethod def init_cache_region(cls, repo_id): - cache_namespace_uid = 'repo.{}'.format(repo_id) + cache_namespace_uid = f'repo.{repo_id}' region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid) return region, cache_namespace_uid @@ -403,8 +401,7 @@ class VcsHttpProxy(object): unpacker = msgpack.Unpacker() for line in result.iter_content(chunk_size=self.CHUNK_SIZE): unpacker.feed(line) - for chunk in unpacker: - yield chunk + yield from unpacker def _get_result(self, result): iterator = self._iterate(result) diff --git a/rhodecode/lib/vcs/conf/__init__.py b/rhodecode/lib/vcs/conf/__init__.py --- a/rhodecode/lib/vcs/conf/__init__.py +++ b/rhodecode/lib/vcs/conf/__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/vcs/conf/mtypes.py b/rhodecode/lib/vcs/conf/mtypes.py --- a/rhodecode/lib/vcs/conf/mtypes.py +++ b/rhodecode/lib/vcs/conf/mtypes.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/conf/settings.py b/rhodecode/lib/vcs/conf/settings.py --- a/rhodecode/lib/vcs/conf/settings.py +++ b/rhodecode/lib/vcs/conf/settings.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -56,8 +54,8 @@ HOOKS_HOST = '127.0.0.1' MERGE_MESSAGE_TMPL = ( - u'Merge pull request !{pr_id} from {source_repo} {source_ref_name}\n\n ' - u'{pr_title}') + 'Merge pull request !{pr_id} from {source_repo} {source_ref_name}\n\n ' + '{pr_title}') MERGE_DRY_RUN_MESSAGE = 'dry_run_merge_message_from_rhodecode' MERGE_DRY_RUN_USER = 'Dry-Run User' MERGE_DRY_RUN_EMAIL = 'dry-run-merge@rhodecode.com' diff --git a/rhodecode/lib/vcs/connection.py b/rhodecode/lib/vcs/connection.py --- a/rhodecode/lib/vcs/connection.py +++ b/rhodecode/lib/vcs/connection.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/exceptions.py b/rhodecode/lib/vcs/exceptions.py --- a/rhodecode/lib/vcs/exceptions.py +++ b/rhodecode/lib/vcs/exceptions.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -222,7 +220,7 @@ def map_vcs_exceptions(func): # replace the first argument with a prefix exc name args = ['{}:{}'.format(exc_name, _args[0] if _args else '?')] + _args[1:] else: - args = [__traceback_info__ or '{}: UnhandledException'.format(exc_name)] + args = [__traceback_info__ or f'{exc_name}: UnhandledException'] if debug or __traceback_info__ and kind not in ['unhandled', 'lookup']: # for other than unhandled errors also log the traceback # can be useful for debugging diff --git a/rhodecode/lib/vcs/geventcurl.py b/rhodecode/lib/vcs/geventcurl.py --- a/rhodecode/lib/vcs/geventcurl.py +++ b/rhodecode/lib/vcs/geventcurl.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/vcs/nodes.py b/rhodecode/lib/vcs/nodes.py --- a/rhodecode/lib/vcs/nodes.py +++ b/rhodecode/lib/vcs/nodes.py @@ -355,7 +355,7 @@ class FileNode(Node): self._set_bulk_properties(pre_load) def __eq__(self, other): - eq = super(FileNode, self).__eq__(other) + eq = super().__eq__(other) if eq is not None: return eq return self.content == other.content @@ -365,7 +365,7 @@ class FileNode(Node): return hash((self.path, raw_id)) def __lt__(self, other): - lt = super(FileNode, self).__lt__(other) + lt = super().__lt__(other) if lt is not None: return lt return self.content < other.content @@ -751,17 +751,16 @@ class DirNode(Node): """ if nodes and commit: raise NodeError("Cannot use both nodes and commit") - super(DirNode, self).__init__(path, NodeKind.DIR) + super().__init__(path, NodeKind.DIR) self.commit = commit self._nodes = nodes self.default_pre_load = default_pre_load or ['is_binary', 'size'] def __iter__(self): - for node in self.nodes: - yield node + yield from self.nodes def __eq__(self, other): - eq = super(DirNode, self).__eq__(other) + eq = super().__eq__(other) if eq is not None: return eq # check without entering each dir @@ -770,7 +769,7 @@ class DirNode(Node): return self_nodes_paths == other_nodes_paths def __lt__(self, other): - lt = super(DirNode, self).__lt__(other) + lt = super().__lt__(other) if lt is not None: return lt # check without entering each dir @@ -788,16 +787,16 @@ class DirNode(Node): nodes = self.commit.get_nodes(self.path, pre_load=self.default_pre_load) else: nodes = self._nodes - self._nodes_dict = dict((node.path, node) for node in nodes) + self._nodes_dict = {node.path: node for node in nodes} return sorted(nodes) @LazyProperty def files(self): - return sorted((node for node in self.nodes if node.is_file())) + return sorted(node for node in self.nodes if node.is_file()) @LazyProperty def dirs(self): - return sorted((node for node in self.nodes if node.is_dir())) + return sorted(node for node in self.nodes if node.is_dir()) def get_node(self, path): """ @@ -873,7 +872,7 @@ class RootNode(DirNode): """ def __init__(self, nodes=(), commit=None): - super(RootNode, self).__init__(path=b'', nodes=nodes, commit=commit) + super().__init__(path=b'', nodes=nodes, commit=commit) def __repr__(self): return f'<{self.__class__.__name__}>' diff --git a/rhodecode/lib/vcs/path.py b/rhodecode/lib/vcs/path.py --- a/rhodecode/lib/vcs/path.py +++ b/rhodecode/lib/vcs/path.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify diff --git a/rhodecode/lib/vcs/utils/__init__.py b/rhodecode/lib/vcs/utils/__init__.py --- a/rhodecode/lib/vcs/utils/__init__.py +++ b/rhodecode/lib/vcs/utils/__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/vcs/utils/helpers.py b/rhodecode/lib/vcs/utils/helpers.py --- a/rhodecode/lib/vcs/utils/helpers.py +++ b/rhodecode/lib/vcs/utils/helpers.py @@ -1,5 +1,3 @@ - - # Copyright (C) 2014-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -51,9 +49,9 @@ def get_scm(path): found_scms = [(scm, path) for scm in get_scms_for_path(path)] if len(found_scms) > 1: - found = ', '.join((x[0] for x in found_scms)) + found = ', '.join(x[0] for x in found_scms) raise VCSError( - 'More than one [%s] scm found at given path %s' % (found, path)) + 'More than one [{}] scm found at given path {}'.format(found, path)) if len(found_scms) == 0: raise VCSError('No scm found at given path %s' % path) diff --git a/rhodecode/lib/vcs/utils/imports.py b/rhodecode/lib/vcs/utils/imports.py --- a/rhodecode/lib/vcs/utils/imports.py +++ b/rhodecode/lib/vcs/utils/imports.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/vcs/utils/paths.py b/rhodecode/lib/vcs/utils/paths.py --- a/rhodecode/lib/vcs/utils/paths.py +++ b/rhodecode/lib/vcs/utils/paths.py @@ -1,4 +1,3 @@ - # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify