diff options
Diffstat (limited to 'git')
| -rw-r--r-- | git/cmd.py | 1 | ||||
| -rw-r--r-- | git/diff.py | 10 | ||||
| -rw-r--r-- | git/exc.py | 2 | ||||
| -rw-r--r-- | git/objects/submodule/base.py | 2 | ||||
| -rw-r--r-- | git/refs/log.py | 37 | ||||
| -rw-r--r-- | git/test/test_docs.py | 2 | ||||
| -rw-r--r-- | git/util.py | 4 |
7 files changed, 31 insertions, 27 deletions
@@ -503,6 +503,7 @@ class Git(LazyMixin): # END readline loop return out + # skipcq: PYL-E0301 def __iter__(self): return self diff --git a/git/diff.py b/git/diff.py index a0076f0c..897228a7 100644 --- a/git/diff.py +++ b/git/diff.py @@ -431,13 +431,14 @@ class Diff(object): text = b''.join(text) index = DiffIndex() previous_header = None - for header in cls.re_header.finditer(text): + header = None + for _header in cls.re_header.finditer(text): a_path_fallback, b_path_fallback, \ old_mode, new_mode, \ rename_from, rename_to, \ new_file_mode, deleted_file_mode, copied_file_name, \ a_blob_id, b_blob_id, b_mode, \ - a_path, b_path = header.groups() + a_path, b_path = _header.groups() new_file, deleted_file, copied_file = \ bool(new_file_mode), bool(deleted_file_mode), bool(copied_file_name) @@ -448,7 +449,7 @@ class Diff(object): # Our only means to find the actual text is to see what has not been matched by our regex, # and then retro-actively assign it to our index if previous_header is not None: - index[-1].diff = text[previous_header.end():header.start()] + index[-1].diff = text[previous_header.end():_header.start()] # end assign actual diff # Make sure the mode is set if the path is set. Otherwise the resulting blob is invalid @@ -467,7 +468,8 @@ class Diff(object): rename_to, None, None, None)) - previous_header = header + previous_header = _header + header = _header # end for each header we parse if index: index[-1].diff = text[header.end():] @@ -5,7 +5,7 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php """ Module containing all exceptions thrown throughout the git package, """ -from gitdb.exc import * # NOQA @UnusedWildImport +from gitdb.exc import * # NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614 from git.compat import UnicodeMixin, safe_decode, string_types diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index bc76bcce..fe2859c6 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -846,7 +846,7 @@ class Submodule(IndexObject, Iterable, Traversable): # have to manually delete references as python's scoping is # not existing, they could keep handles open ( on windows this is a problem ) if len(rrefs): - del(rref) + del(rref) # skipcq:PYL-W0631 # END handle remotes del(rrefs) del(remote) diff --git a/git/refs/log.py b/git/refs/log.py index e8c2d7ad..bc6d4486 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -84,7 +84,7 @@ class RefLogEntry(tuple): return self[4] @classmethod - def new(self, oldhexsha, newhexsha, actor, time, tz_offset, message): + def new(cls, oldhexsha, newhexsha, actor, time, tz_offset, message): """:return: New instance of a RefLogEntry""" if not isinstance(actor, Actor): raise ValueError("Need actor instance, got %s" % actor) @@ -217,23 +217,24 @@ class RefLog(list, Serializable): the index is negative """ fp = open(filepath, 'rb') - if index < 0: - return RefLogEntry.from_line(fp.readlines()[index].strip()) - else: - # read until index is reached - for i in xrange(index + 1): - line = fp.readline() - if not line: - break - # END abort on eof - # END handle runup - - if i != index or not line: - raise IndexError - # END handle exception - - return RefLogEntry.from_line(line.strip()) - # END handle index + with open(filepath, 'rb') as fp: + if index < 0: + return RefLogEntry.from_line(fp.readlines()[index].strip()) + else: + # read until index is reached + for i in xrange(index + 1): + line = fp.readline() + if not line: + break + # END abort on eof + # END handle runup + + if i != index or not line: # skipcq:PYL-W0631 + raise IndexError + # END handle exception + + return RefLogEntry.from_line(line.strip()) + # END handle index def to_file(self, filepath): """Write the contents of the reflog instance to a file at the given filepath. diff --git a/git/test/test_docs.py b/git/test/test_docs.py index a1fea454..a393ded8 100644 --- a/git/test/test_docs.py +++ b/git/test/test_docs.py @@ -349,7 +349,7 @@ class Tutorials(TestBase): # The index contains all blobs in a flat list assert len(list(index.iter_blobs())) == len([o for o in repo.head.commit.tree.traverse() if o.type == 'blob']) # Access blob objects - for (path, _stage), entry in index.entries.items(): + for (_path, _stage), entry in index.entries.items(): pass new_file_path = os.path.join(repo.working_tree_dir, 'new-file-name') open(new_file_path, 'w').close() diff --git a/git/util.py b/git/util.py index 99600e37..974657e6 100644 --- a/git/util.py +++ b/git/util.py @@ -133,7 +133,7 @@ def join_path(a, *p): '/' instead of possibly '\' on windows.""" path = a for b in p: - if len(b) == 0: + if not b: continue if b.startswith('/'): path += b[1:] @@ -386,7 +386,7 @@ class RemoteProgress(object): # Compressing objects: 100% (2/2) # Compressing objects: 100% (2/2), done. self._cur_line = line = line.decode('utf-8') if isinstance(line, bytes) else line - if len(self.error_lines) > 0 or self._cur_line.startswith(('error:', 'fatal:')): + if self.error_lines or self._cur_line.startswith(('error:', 'fatal:')): self.error_lines.append(self._cur_line) return |
