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 @@ -910,8 +910,7 @@ def add_field_to_repo(request, apiuser, field = RepositoryField.get_by_key_name(key, repo) if field: - raise JSONRPCError('Field with key ' - '`%s` exists for repo `%s`' % (key, repoid)) + raise JSONRPCError(f'Field with key `{key}` exists for repo `{repoid}`') try: RepoModel().add_repo_field(repo, key, field_label=label, diff --git a/rhodecode/apps/my_account/tests/test_my_account_password.py b/rhodecode/apps/my_account/tests/test_my_account_password.py --- a/rhodecode/apps/my_account/tests/test_my_account_password.py +++ b/rhodecode/apps/my_account/tests/test_my_account_password.py @@ -20,13 +20,11 @@ import pytest import mock -from rhodecode.apps._base import ADMIN_PREFIX -from rhodecode.lib import helpers as h from rhodecode.lib.auth import check_password from rhodecode.model.meta import Session from rhodecode.model.user import UserModel -from rhodecode.tests import assert_session_flash -from rhodecode.tests.fixture import Fixture, TestController, error_function +from rhodecode.tests import assert_session_flash, TestController +from rhodecode.tests.fixture import Fixture, error_function from rhodecode.tests.routes import route_path fixture = Fixture() diff --git a/rhodecode/lib/system_info.py b/rhodecode/lib/system_info.py --- a/rhodecode/lib/system_info.py +++ b/rhodecode/lib/system_info.py @@ -265,8 +265,7 @@ def memory(): value.update(dict(psutil.virtual_memory()._asdict())) value['used_real'] = value['total'] - value['available'] - value['percent_used'] = psutil._common.usage_percent( - value['used_real'], value['total'], 1) + value['percent_used'] = psutil._common.usage_percent(value['used_real'], value['total'], 1) human_value = value.copy() human_value['text'] = '{}/{}, {}% used'.format( @@ -324,8 +323,7 @@ def cpu(): value['cpu_count'] = psutil.cpu_count() human_value = value.copy() - human_value['text'] = '{} cores at {} %'.format( - value['cpu_count'], value['cpu']) + human_value['text'] = '{} cores at {} %'.format(value['cpu_count'], value['cpu']) return SysInfoRes(value=value, state=state, human_value=human_value) @@ -784,10 +782,10 @@ def server_info(environ): @register_sysinfo def usage_info(): - from rhodecode.model.db import User, Repository + from rhodecode.model.db import User, Repository, true value = { 'users': User.query().count(), - 'users_active': User.query().filter(User.active == True).count(), + 'users_active': User.query().filter(User.active == true()).count(), 'repositories': Repository.query().count(), 'repository_types': { 'hg': Repository.query().filter( diff --git a/rhodecode/lib/utils2.py b/rhodecode/lib/utils2.py --- a/rhodecode/lib/utils2.py +++ b/rhodecode/lib/utils2.py @@ -969,7 +969,7 @@ def user_agent_normalizer(user_agent_raw def get_available_port(min_port=40000, max_port=55555, use_range=False): hostname = '' - for _ in range(min_port, max_port): + for _check_port in range(min_port, max_port): pick_port = 0 if use_range: pick_port = random.randint(min_port, max_port) @@ -979,9 +979,9 @@ def get_available_port(min_port=40000, m s.bind((hostname, pick_port)) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) return s.getsockname()[1] - except OSError: - continue except socket.error as e: if e.args[0] in [errno.EADDRINUSE, errno.ECONNREFUSED]: continue raise + except OSError: + continue 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 @@ -237,7 +237,7 @@ class MergeResponse(object): } - def __init__(self, possible, executed, merge_ref, failure_reason, metadata=None): + def __init__(self, possible, executed, merge_ref: Reference, failure_reason, metadata=None): self.possible = possible self.executed = executed self.merge_ref = merge_ref 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 @@ -954,6 +954,7 @@ class GitRepository(BaseRepository): log.debug('Executing merge_repo with %s strategy, dry_run mode:%s', 'rebase' if use_rebase else 'merge', dry_run) + if target_ref.commit_id != self.branches[target_ref.name]: log.warning('Target ref %s commit mismatch %s vs %s', target_ref, target_ref.commit_id, self.branches[target_ref.name]) diff --git a/rhodecode/tests/fixture.py b/rhodecode/tests/fixture.py --- a/rhodecode/tests/fixture.py +++ b/rhodecode/tests/fixture.py @@ -28,7 +28,6 @@ import shutil import configparser from rhodecode.model.settings import SettingsModel -from rhodecode.tests import * from rhodecode.model.db import Repository, User, RepoGroup, UserGroup, Gist, UserEmailMap from rhodecode.model.meta import Session from rhodecode.model.repo import RepoModel @@ -41,6 +40,8 @@ from rhodecode.model.scm import ScmModel from rhodecode.authentication.plugins.auth_rhodecode import \ RhodeCodeAuthPlugin +from rhodecode.tests import TEST_USER_ADMIN_LOGIN + dn = os.path.dirname FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'tests', 'fixtures') @@ -291,7 +292,7 @@ class Fixture(object): repo_type=repo_to_fork.repo_type, **kwargs) - #TODO: fix it !! + # TODO: fix it !! form_data['description'] = form_data['repo_description'] form_data['private'] = form_data['repo_private'] form_data['landing_rev'] = form_data['repo_landing_commit_ref'] diff --git a/rhodecode/tests/lib/test_diffs.py b/rhodecode/tests/lib/test_diffs.py --- a/rhodecode/tests/lib/test_diffs.py +++ b/rhodecode/tests/lib/test_diffs.py @@ -27,10 +27,11 @@ from rhodecode.lib.diffs import ( DiffProcessor, NEW_FILENODE, DEL_FILENODE, MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE, COPIED_FILENODE) -from rhodecode.lib.str_utils import safe_bytes + from rhodecode.lib.utils2 import AttributeDict from rhodecode.lib.vcs.backends.git import GitCommit -from rhodecode.tests.fixture import Fixture, no_newline_id_generator +from rhodecode.tests.fixture import Fixture +from rhodecode.tests import no_newline_id_generator from rhodecode.lib.vcs.backends.git.repository import GitDiff from rhodecode.lib.vcs.backends.hg.repository import MercurialDiff from rhodecode.lib.vcs.backends.svn.repository import SubversionDiff