# HG changeset patch # User RhodeCode Admin # Date 2023-10-13 11:58:26 # Node ID 0f2a89071c2737f8e749872762f470b970dd79fc # Parent a31fb4ad444671d819ca2827cf0df3203dbec782 lint: use null() to compare to == None for linters to be happy 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 @@ -35,7 +35,7 @@ from rhodecode.lib import hooks_base from rhodecode.lib.utils2 import safe_int, str2bool, aslist from rhodecode.lib.statsd_client import StatsdClient from rhodecode.model.db import ( - Session, IntegrityError, true, Repository, RepoGroup, User) + true, null, Session, IntegrityError, Repository, RepoGroup, User) from rhodecode.model.permission import PermissionModel @@ -393,7 +393,7 @@ def sync_last_update_for_objects(*args, skip_groups = kwargs.get('skip_groups') if not skip_groups: repo_groups = RepoGroup.query() \ - .filter(RepoGroup.group_parent_id == None) + .filter(RepoGroup.group_parent_id == null()) for root_gr in repo_groups: for repo_gr in reversed(root_gr.recursive_groups()): diff --git a/rhodecode/model/changeset_status.py b/rhodecode/model/changeset_status.py --- a/rhodecode/model/changeset_status.py +++ b/rhodecode/model/changeset_status.py @@ -23,7 +23,7 @@ import collections from rhodecode.model import BaseModel from rhodecode.model.db import ( - ChangesetStatus, ChangesetComment, PullRequest, PullRequestReviewers, Session) + null, ChangesetStatus, ChangesetComment, PullRequest, PullRequestReviewers, Session) from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError from rhodecode.lib.markup_renderer import ( DEFAULT_COMMENTS_RENDERER, RstTemplateRenderer) @@ -60,7 +60,7 @@ class ChangesetStatusModel(BaseModel): # the pull_request_version_id. q = q.join(ChangesetComment).filter( ChangesetStatus.pull_request == pull_request, - ChangesetComment.pull_request_version_id == None) + ChangesetComment.pull_request_version_id == null()) else: raise Exception('Please specify revision or pull_request') q = q.order_by(ChangesetStatus.version.asc()) diff --git a/rhodecode/model/comment.py b/rhodecode/model/comment.py --- a/rhodecode/model/comment.py +++ b/rhodecode/model/comment.py @@ -151,7 +151,7 @@ class CommentsModel(BaseModel): def get_repository_unresolved_todos(self, repo): todos = Session().query(ChangesetComment) \ .filter(ChangesetComment.repo == repo) \ - .filter(ChangesetComment.resolved_by == None) \ + .filter(ChangesetComment.resolved_by == null()) \ .filter(ChangesetComment.comment_type == ChangesetComment.COMMENT_TYPE_TODO) todos = todos.all() @@ -162,7 +162,7 @@ class CommentsModel(BaseModel): todos = Session().query(ChangesetComment) \ .filter(ChangesetComment.pull_request == pull_request) \ - .filter(ChangesetComment.resolved_by == None) \ + .filter(ChangesetComment.resolved_by == null()) \ .filter(ChangesetComment.comment_type == ChangesetComment.COMMENT_TYPE_TODO) @@ -209,7 +209,7 @@ class CommentsModel(BaseModel): todos = Session().query(ChangesetComment) \ .filter(ChangesetComment.revision == commit_id) \ - .filter(ChangesetComment.resolved_by == None) \ + .filter(ChangesetComment.resolved_by == null()) \ .filter(ChangesetComment.comment_type == ChangesetComment.COMMENT_TYPE_TODO) @@ -635,8 +635,8 @@ class CommentsModel(BaseModel): q = ChangesetComment.query()\ .filter(ChangesetComment.repo_id == repo_id)\ - .filter(ChangesetComment.line_no == None)\ - .filter(ChangesetComment.f_path == None) + .filter(ChangesetComment.line_no == null())\ + .filter(ChangesetComment.f_path == null()) if revision: q = q.filter(ChangesetComment.revision == revision) elif pull_request: @@ -780,15 +780,15 @@ class CommentsModel(BaseModel): def _all_inline_comments_of_pull_request(self, pull_request): comments = Session().query(ChangesetComment)\ - .filter(ChangesetComment.line_no != None)\ - .filter(ChangesetComment.f_path != None)\ + .filter(ChangesetComment.line_no != null())\ + .filter(ChangesetComment.f_path != null())\ .filter(ChangesetComment.pull_request == pull_request) return comments def _all_general_comments_of_pull_request(self, pull_request): comments = Session().query(ChangesetComment)\ - .filter(ChangesetComment.line_no == None)\ - .filter(ChangesetComment.f_path == None)\ + .filter(ChangesetComment.line_no == null())\ + .filter(ChangesetComment.f_path == null())\ .filter(ChangesetComment.pull_request == pull_request) return comments diff --git a/rhodecode/model/integration.py b/rhodecode/model/integration.py --- a/rhodecode/model/integration.py +++ b/rhodecode/model/integration.py @@ -122,12 +122,12 @@ class IntegrationModel(BaseModel): elif scope == 'global': # global integrations query = self.sa.query(Integration).filter( - and_(Integration.repo_id == None, Integration.repo_group_id == None) + and_(Integration.repo_id == null(), Integration.repo_group_id == null()) ) elif scope == 'root-repos': query = self.sa.query(Integration).filter( - and_(Integration.repo_id == None, - Integration.repo_group_id == None, + and_(Integration.repo_id == null(), + Integration.repo_group_id == null(), Integration.child_repos_only == true()) ) elif scope == 'all': diff --git a/rhodecode/model/pull_request.py b/rhodecode/model/pull_request.py --- a/rhodecode/model/pull_request.py +++ b/rhodecode/model/pull_request.py @@ -1316,7 +1316,7 @@ class PullRequestModel(BaseModel): # to either the source repo, the target repo or no repo at all. ChangesetComment.repo_id == pull_request.target_repo.repo_id, ChangesetComment.pull_request == pull_request, - ChangesetComment.pull_request_version == None)\ + ChangesetComment.pull_request_version == null())\ .order_by(ChangesetComment.comment_id.asc()) # TODO: johbo: Find out why this breaks if it is done in a bulk diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -46,7 +46,7 @@ from rhodecode.lib.str_utils import safe from rhodecode.lib.system_info import get_system_info from rhodecode.model import BaseModel from rhodecode.model.db import ( - or_, false, + or_, false, null, Repository, CacheKey, UserFollowing, UserLog, User, RepoGroup, PullRequest, FileStore) from rhodecode.model.settings import VcsSettingsModel @@ -249,7 +249,7 @@ class ScmModel(BaseModel): """ if all_repos is None: all_repos = self.sa.query(Repository)\ - .filter(Repository.group_id == None)\ + .filter(Repository.group_id == null())\ .order_by(func.lower(Repository.repo_name)).all() repo_iter = SimpleCachedRepoList( all_repos, repos_path=self.repos_path, order_by=sort_key) @@ -258,7 +258,7 @@ class ScmModel(BaseModel): def get_repo_groups(self, all_groups=None): if all_groups is None: all_groups = RepoGroup.query()\ - .filter(RepoGroup.group_parent_id == None).all() + .filter(RepoGroup.group_parent_id == null()).all() return [x for x in RepoGroupList(all_groups)] def mark_for_invalidation(self, repo_name, delete=False): @@ -371,7 +371,7 @@ class ScmModel(BaseModel): repo = self._get_repo(repo) return self.sa.query(FileStore)\ .filter(FileStore.repo == repo)\ - .filter(or_(FileStore.hidden == None, FileStore.hidden == false())).count() + .filter(or_(FileStore.hidden == null(), FileStore.hidden == false())).count() def mark_as_fork(self, repo, fork, user): repo = self._get_repo(repo)