diff --git a/AUTHORS b/AUTHORS index a7a19d549..c8604bfc2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,6 +34,7 @@ Contributors are: -Stefan Stancu -César Izurieta -Arthur Milchior +-Anil Khatri -JJ Graham Portions derived from other open source works and are clearly marked. diff --git a/git/cmd.py b/git/cmd.py index 484a0181a..a13556aa9 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -503,6 +503,7 @@ def readlines(self, size=-1): # END readline loop return out + # skipcq: PYL-E0301 def __iter__(self): return self diff --git a/git/diff.py b/git/diff.py index a0076f0cf..897228a71 100644 --- a/git/diff.py +++ b/git/diff.py @@ -431,13 +431,14 @@ def _index_from_patch_format(cls, repo, proc): 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 @@ def _index_from_patch_format(cls, repo, proc): # 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 @@ def _index_from_patch_format(cls, repo, proc): 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():] diff --git a/git/exc.py b/git/exc.py index 4865da944..1c4d50056 100644 --- a/git/exc.py +++ b/git/exc.py @@ -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 bc76bcceb..04ca02218 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -846,7 +846,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False): # 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 e8c2d7ada..432232ac7 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -84,7 +84,7 @@ def message(self): return self[4] @classmethod - def new(self, oldhexsha, newhexsha, actor, time, tz_offset, message): + def new(cls, oldhexsha, newhexsha, actor, time, tz_offset, message): # skipcq: PYL-W0621 """:return: New instance of a RefLogEntry""" if not isinstance(actor, Actor): raise ValueError("Need actor instance, got %s" % actor) @@ -121,7 +121,7 @@ def from_line(cls, line): # END handle missing end brace actor = Actor._from_string(info[82:email_end + 1]) - time, tz_offset = parse_date(info[email_end + 2:]) + time, tz_offset = parse_date(info[email_end + 2:]) # skipcq: PYL-W0621 return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), msg)) @@ -216,10 +216,9 @@ def entry_at(cls, filepath, index): all other lines. Nonetheless, the whole file has to be read if the index is negative """ - fp = open(filepath, 'rb') - if index < 0: - return RefLogEntry.from_line(fp.readlines()[index].strip()) - else: + with open(filepath, 'rb') as fp: + if index < 0: + return RefLogEntry.from_line(fp.readlines()[index].strip()) # read until index is reached for i in xrange(index + 1): line = fp.readline() @@ -228,7 +227,7 @@ def entry_at(cls, filepath, index): # END abort on eof # END handle runup - if i != index or not line: + if i != index or not line: # skipcq:PYL-W0631 raise IndexError # END handle exception diff --git a/git/test/test_docs.py b/git/test/test_docs.py index a1fea4540..a393ded8d 100644 --- a/git/test/test_docs.py +++ b/git/test/test_docs.py @@ -349,7 +349,7 @@ def test_references_and_objects(self, rw_dir): # 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 99600e377..974657e6f 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 @@ def _parse_progress_line(self, line): # 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