summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorAnil Khatri <anil.soccer.khatri@gmail.com>2019-10-23 23:06:48 +0530
committerAnil Khatri <anil.soccer.khatri@gmail.com>2019-10-23 23:06:48 +0530
commit5eb8289e80c8b9fe48456e769e0421b7f9972af3 (patch)
tree98a7e88b0a1df5f0ba741f476945c3d57a19e655 /git
parent607d8aa3461e764cbe008f2878c2ac0fa79cf910 (diff)
downloadgitpython-5eb8289e80c8b9fe48456e769e0421b7f9972af3.tar.gz
fix Loop variable used outside the loop
Diffstat (limited to 'git')
-rw-r--r--git/diff.py10
-rw-r--r--git/objects/submodule/base.py2
-rw-r--r--git/refs/log.py2
-rw-r--r--git/util.py4
4 files changed, 10 insertions, 8 deletions
diff --git a/git/diff.py b/git/diff.py
index 10cb9f02..6a5d51cc 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -415,13 +415,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, \
a_blob_id, b_blob_id, b_mode, \
- a_path, b_path = header.groups()
+ a_path, b_path = _header.groups()
new_file, deleted_file = bool(new_file_mode), bool(deleted_file_mode)
@@ -431,7 +432,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
@@ -450,7 +451,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():]
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 8d557902..01673ae0 100644
--- a/git/refs/log.py
+++ b/git/refs/log.py
@@ -228,7 +228,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/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