Changeset - bbd96bdf8372
[Not reviewed]
default
0 1 0
Mads Kiilerich - 5 years ago 2020-10-10 13:16:59
mads@kiilerich.com
Grafted from: 911d2c5f8ca1
scm: make sure __get_repo always returns something

Avoid pytype complaint:
File ".../kallithea/model/scm.py", line 438, in get_nodes: No attribute 'scm_instance' on None [attribute-error]
In Optional[Any]

Avoid invoking __get_repo with None as parameter when creating repos.
1 file changed with 3 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/model/scm.py
Show inline comments
 
@@ -145,9 +145,8 @@ class ScmModel(object):
 
            if instance.isdigit():
 
                return cls.get(int(instance))
 
            return cls.get_by_repo_name(instance)
 
        elif instance is not None:
 
            raise Exception('given object must be int, basestr or Instance'
 
                            ' of %s got %s' % (type(cls), type(instance)))
 
        raise Exception('given object must be int, basestr or Instance'
 
                        ' of %s got %s' % (type(cls), type(instance)))
 

	
 
    @LazyProperty
 
    def repos_path(self):
 
@@ -651,12 +650,12 @@ class ScmModel(object):
 

	
 
        hist_l = []
 
        choices = []
 
        repo = self.__get_repo(repo)
 
        hist_l.append(('rev:tip', _('latest tip')))
 
        choices.append('rev:tip')
 
        if repo is None:
 
            return choices, hist_l
 

	
 
        repo = self.__get_repo(repo)
 
        repo = repo.scm_instance
 

	
 
        branches_group = ([('branch:%s' % k, k) for k, v in
0 comments (0 inline, 0 general)