diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2019-10-29 08:31:39 +0100 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2019-10-29 08:31:39 +0100 |
commit | 52ee6c19423297b4c667d34ed1bd621dafaabb0e (patch) | |
tree | 5ac04998b1f5b0fba24297e97f5592c74b617688 | |
parent | 553500a3447667aaa9bd3b922742575562c03b68 (diff) | |
parent | 9932e647aaaaf6edd3a407b75edd08a96132ef5c (diff) | |
download | gitpython-52ee6c19423297b4c667d34ed1bd621dafaabb0e.tar.gz |
Merge branch 'fix/deepsource-issues' of https://github.com/imkaka/GitPython into imkaka-fix/deepsource-issues
-rw-r--r-- | AUTHORS | 1 | ||||
-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 | 13 | ||||
-rw-r--r-- | git/test/test_docs.py | 2 | ||||
-rw-r--r-- | git/util.py | 4 |
8 files changed, 19 insertions, 16 deletions
@@ -34,6 +34,7 @@ Contributors are: -Stefan Stancu <stefan.stancu _at_ gmail.com> -César Izurieta <cesar _at_ caih.org> -Arthur Milchior <arthur _at_ milchior.fr> +-Anil Khatri <anil.soccer.khatri _at_ gmail.com> -JJ Graham <thetwoj _at_ gmail.com> -Ben Thayer <ben _at_ benthayer.com> @@ -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 fcf40f2b..7a06f3a1 100644 --- a/git/diff.py +++ b/git/diff.py @@ -432,13 +432,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) @@ -449,7 +450,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 @@ -468,7 +469,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..04ca0221 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..432232ac 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): # 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 @@ class RefLogEntry(tuple): # 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 @@ class RefLog(list, Serializable): 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 @@ class RefLog(list, Serializable): # 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 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 |