# HG changeset patch # User Mads Kiilerich # Date 1580741182 -3600 # Node ID 95ca00cd722f8d1caef7526d4f0b37411864b8b3 # Parent 09225e4526120da43c57677fde43b5ba0849a7ad cleanup: minor correctness fixes "Trivial" potential problems spotted with pytype. diff -r 09225e452612 -r 95ca00cd722f kallithea/controllers/admin/repo_groups.py --- a/kallithea/controllers/admin/repo_groups.py Sat Jan 18 07:42:24 2020 +0100 +++ b/kallithea/controllers/admin/repo_groups.py Mon Feb 03 15:46:22 2020 +0100 @@ -148,6 +148,7 @@ # permissions for can create group based on parent_id are checked # here in the Form repo_group_form = RepoGroupForm(repo_groups=c.repo_groups) + form_result = None try: form_result = repo_group_form.to_python(dict(request.POST)) gr = RepoGroupModel().create( @@ -171,6 +172,8 @@ log.error(traceback.format_exc()) h.flash(_('Error occurred during creation of repository group %s') % request.POST.get('group_name'), category='error') + if form_result is None: + raise parent_group_id = form_result['parent_group_id'] # TODO: maybe we should get back to the main view, not the admin one raise HTTPFound(location=url('repos_groups', parent_group=parent_group_id)) diff -r 09225e452612 -r 95ca00cd722f kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py Sat Jan 18 07:42:24 2020 +0100 +++ b/kallithea/controllers/pullrequests.py Mon Feb 03 15:46:22 2020 +0100 @@ -470,14 +470,15 @@ c.a_rev) = c.pull_request.other_ref.split(':') # a_rev is ancestor org_scm_instance = c.cs_repo.scm_instance # property with expensive cache invalidation check!!! - try: - c.cs_ranges = [] - for x in c.pull_request.revisions: + c.cs_ranges = [] + for x in c.pull_request.revisions: + try: c.cs_ranges.append(org_scm_instance.get_changeset(x)) - except ChangesetDoesNotExistError: - c.cs_ranges = [] - h.flash(_('Revision %s not found in %s') % (x, c.cs_repo.repo_name), - 'error') + except ChangesetDoesNotExistError: + c.cs_ranges = [] + h.flash(_('Revision %s not found in %s') % (x, c.cs_repo.repo_name), + 'error') + break c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ... revs = [ctx.revision for ctx in reversed(c.cs_ranges)] c.jsdata = graph_data(org_scm_instance, revs) diff -r 09225e452612 -r 95ca00cd722f kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py Sat Jan 18 07:42:24 2020 +0100 +++ b/kallithea/lib/diffs.py Mon Feb 03 15:46:22 2020 +0100 @@ -557,8 +557,8 @@ added = deleted = 0 old_line = old_end = new_line = new_end = None + chunks = [] try: - chunks = [] line = diff_lines.next() while True: diff -r 09225e452612 -r 95ca00cd722f kallithea/lib/utils2.py --- a/kallithea/lib/utils2.py Sat Jan 18 07:42:24 2020 +0100 +++ b/kallithea/lib/utils2.py Mon Feb 03 15:46:22 2020 +0100 @@ -374,7 +374,7 @@ :returns: filtered list of strings """ if not uri: - return '' + return [] proto = '' @@ -541,11 +541,11 @@ raise HookEnvironmentError("Environment variable KALLITHEA_EXTRAS not found") extras = json.loads(kallithea_extras) - try: - for k in ['username', 'repository', 'scm', 'action', 'ip', 'config']: + for k in ['username', 'repository', 'scm', 'action', 'ip', 'config']: + try: extras[k] - except KeyError: - raise HookEnvironmentError('Missing key %s in KALLITHEA_EXTRAS %s' % (k, extras)) + except KeyError: + raise HookEnvironmentError('Missing key %s in KALLITHEA_EXTRAS %s' % (k, extras)) return AttributeDict(extras) diff -r 09225e452612 -r 95ca00cd722f kallithea/lib/vcs/nodes.py --- a/kallithea/lib/vcs/nodes.py Sat Jan 18 07:42:24 2020 +0100 +++ b/kallithea/lib/vcs/nodes.py Mon Feb 03 15:46:22 2020 +0100 @@ -329,8 +329,8 @@ encoding = None # try with pygments + from pygments import lexers try: - from pygments import lexers mt = lexers.get_lexer_for_filename(self.name).mimetypes except lexers.ClassNotFound: mt = None