diff --git a/git/cmd.py b/git/cmd.py index 50b1e3212..2d288b25f 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -375,7 +375,6 @@ def __del__(self): proc.wait() # ensure process goes away except OSError as ex: log.info("Ignored error after process had died: %r", ex) - pass # ignore error when process already died except AttributeError: # try windows # for some reason, providing None for stdout/stderr still prints something. This is why diff --git a/git/compat.py b/git/compat.py index 02dc69de8..e88ca9b56 100644 --- a/git/compat.py +++ b/git/compat.py @@ -145,14 +145,12 @@ def __str__(self): def u(text): if PY3: return text - else: - return text.decode('unicode_escape') + return text.decode('unicode_escape') def b(data): if PY3: return data.encode('latin1') - else: - return data + return data if PY3: _unichr = chr @@ -282,8 +280,7 @@ def encodefilename(fn): ch_utf8 = ch.encode('utf-8') encoded.append(ch_utf8) return bytes().join(encoded) - else: - return fn.encode(FS_ENCODING, FS_ERRORS) + return fn.encode(FS_ENCODING, FS_ERRORS) def decodefilename(fn): return fn.decode(FS_ENCODING, FS_ERRORS) diff --git a/git/config.py b/git/config.py index b03d9d42e..edd5750bf 100644 --- a/git/config.py +++ b/git/config.py @@ -339,8 +339,7 @@ def string_decode(v): if PY3: return v.encode(defenc).decode('unicode_escape') - else: - return v.decode('string_escape') + return v.decode('string_escape') # end # end diff --git a/git/index/fun.py b/git/index/fun.py index f0091a3a1..5906a358b 100644 --- a/git/index/fun.py +++ b/git/index/fun.py @@ -173,8 +173,7 @@ def entry_key(*entry): :param entry: One instance of type BaseIndexEntry or the path and the stage""" if len(entry) == 1: return (entry[0].path, entry[0].stage) - else: - return tuple(entry) + return tuple(entry) # END handle entry diff --git a/git/objects/commit.py b/git/objects/commit.py index 997fc5909..f7201d90e 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -174,8 +174,7 @@ def count(self, paths='', **kwargs): # as the empty paths version will ignore merge commits for some reason. if paths: return len(self.repo.git.rev_list(self.hexsha, '--', paths, **kwargs).splitlines()) - else: - return len(self.repo.git.rev_list(self.hexsha, **kwargs).splitlines()) + return len(self.repo.git.rev_list(self.hexsha, **kwargs).splitlines()) @property def name_rev(self): diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 384f7c5fc..bc76bcceb 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -233,8 +233,7 @@ def _config_parser_constrained(self, read_only): def _module_abspath(cls, parent_repo, path, name): if cls._need_gitfile_submodules(parent_repo.git): return osp.join(parent_repo.git_dir, 'modules', name) - else: - return osp.join(parent_repo.working_tree_dir, path) + return osp.join(parent_repo.working_tree_dir, path) # end @classmethod diff --git a/git/refs/head.py b/git/refs/head.py index 4b0abb062..cc8385908 100644 --- a/git/refs/head.py +++ b/git/refs/head.py @@ -219,8 +219,7 @@ def checkout(self, force=False, **kwargs): self.repo.git.checkout(self, **kwargs) if self.repo.head.is_detached: return self.repo.head - else: - return self.repo.active_branch + return self.repo.active_branch #{ Configuration def _config_parser(self, read_only): diff --git a/git/refs/log.py b/git/refs/log.py index fc962680c..e8c2d7ada 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -39,10 +39,9 @@ def __repr__(self): res = self.format() if PY3: return res - else: - # repr must return a string, which it will auto-encode from unicode using the default encoding. - # This usually fails, so we encode ourselves - return res.encode(defenc) + # repr must return a string, which it will auto-encode from unicode using the default encoding. + # This usually fails, so we encode ourselves + return res.encode(defenc) def format(self): """:return: a string suitable to be placed in a reflog file""" diff --git a/git/remote.py b/git/remote.py index e7b3579bc..23337a9c8 100644 --- a/git/remote.py +++ b/git/remote.py @@ -75,8 +75,7 @@ def to_progress_instance(progress): return RemoteProgress() # assume its the old API with an instance of RemoteProgress. - else: - return progress + return progress class PushInfo(object): diff --git a/git/repo/base.py b/git/repo/base.py index 4d7011533..106ed2ebe 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -478,8 +478,7 @@ def commit(self, rev=None): :return: ``git.Commit``""" if rev is None: return self.head.commit - else: - return self.rev_parse(text_type(rev) + "^0") + return self.rev_parse(text_type(rev) + "^0") def iter_trees(self, *args, **kwargs): """:return: Iterator yielding Tree objects @@ -501,8 +500,7 @@ def tree(self, rev=None): operations might have unexpected results.""" if rev is None: return self.head.commit.tree - else: - return self.rev_parse(text_type(rev) + "^{tree}") + return self.rev_parse(text_type(rev) + "^{tree}") def iter_commits(self, rev=None, paths='', **kwargs): """A list of Commit objects representing the history of a given ref/commit @@ -601,8 +599,7 @@ def _get_alternates(self): with open(alternates_path, 'rb') as f: alts = f.read().decode(defenc) return alts.strip().splitlines() - else: - return [] + return [] def _set_alternates(self, alts): """Sets the alternates diff --git a/git/util.py b/git/util.py index c395afd26..99600e377 100644 --- a/git/util.py +++ b/git/util.py @@ -577,9 +577,8 @@ def _from_string(cls, string): m = cls.name_only_regex.search(string) if m: return Actor(m.group(1), None) - else: - # assume best and use the whole string as name - return Actor(string, None) + # assume best and use the whole string as name + return Actor(string, None) # END special case name # END handle name/email matching