Skip to content

Commit

Permalink
Fix flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ishepard committed Aug 5, 2023
1 parent daa5c37 commit a1c287c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pydriller/domain/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ def diff(self) -> str:

def _get_decoded_str(self, diff: Union[str, bytes, None]) -> Optional[str]:
try:
if type(diff) == bytes:
if isinstance(diff, bytes):
return diff.decode("utf-8", "ignore")
if type(diff) == str:
if isinstance(diff, str):
return diff
return None
except (AttributeError, ValueError):
Expand All @@ -224,14 +224,14 @@ def _get_undecoded_content(self, blob: Optional[IndexObject]) -> Optional[bytes]

@property
def source_code(self) -> Optional[str]:
if self.content and type(self.content) == bytes:
if self.content and isinstance(self.content, bytes):
return self._get_decoded_content(self.content)

return None

@property
def source_code_before(self) -> Optional[str]:
if self.content_before and type(self.content_before) == bytes:
if self.content_before and isinstance(self.content_before, bytes):
return self._get_decoded_content(self.content_before)

return None
Expand Down
8 changes: 4 additions & 4 deletions tests/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,14 @@ def test_commit_dictset(repo: Git):

commit_dict = {c1: c1.hash, c2: c2.hash, c3: c3.hash}

assert type(commit_dict) == dict
assert isinstance(commit_dict, dict)
assert commit_dict[c1] == "e7d13b0511f8a176284ce4f92ed8c6e8d09c77f2"
assert commit_dict[c2] == c1.parents[0]
assert commit_dict[c3] == "a4ece0762e797d2e2dcbd471115108dd6e05ff58"
assert commit_dict[c1] != commit_dict[c2]

commit_set = {c1, c2, c3}
assert type(commit_set) == set
assert isinstance(commit_set, set)
assert c1 in commit_set
assert commit_set - {c1} == {c2, c3}

Expand All @@ -411,13 +411,13 @@ def test_modification_dictset(repo: Git):

mod_dict = {m1: c1, m2s[0]: c2, m2s[1]: c2}

assert type(mod_dict) == dict
assert isinstance(mod_dict, dict)
assert mod_dict[m1].hash == "e7d13b0511f8a176284ce4f92ed8c6e8d09c77f2"
assert mod_dict[m2s[0]].hash == c1.parents[0]
assert mod_dict[m2s[1]].hash == c1.parents[0]
assert m1 != m2s[0]

mod_set = {m1}.union(set(m2s))
assert type(mod_set) == set
assert isinstance(mod_set, set)
assert m1 in mod_set
assert mod_set - {m1} == set(m2s)

0 comments on commit a1c287c

Please sign in to comment.