Skip to content

Fix/deepsource issues #952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Portions derived from other open source works and are clearly marked.
1 change: 1 addition & 0 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def readlines(self, size=-1):
# END readline loop
return out

# skipcq: PYL-E0301
def __iter__(self):
return self

Expand Down
10 changes: 6 additions & 4 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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():]
Expand Down
2 changes: 1 addition & 1 deletion git/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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()
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion git/test/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand Down Expand Up @@ -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

Expand Down