Skip to content

Commit

Permalink
Use "is" to compare __class__
Browse files Browse the repository at this point in the history
Since the value of __class__ is a type, comparing it to another
type object should use "is" rather than "==".

Some of these, involving type(), were fixed in bf7af69, but flake8
did not catch the .__class__ variation addressed here.
  • Loading branch information
EliahKagan committed Oct 22, 2023
1 parent 59d208c commit add46d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ def iter_items(
List is lexicographically sorted
The returned objects represent actual subclasses, such as Head or TagReference"""
return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached)
return (r for r in cls._iter_items(repo, common_path) if r.__class__ is SymbolicReference or not r.is_detached)

@classmethod
def from_path(cls: Type[T_References], repo: "Repo", path: PathLike) -> T_References:
Expand Down Expand Up @@ -797,7 +797,7 @@ def from_path(cls: Type[T_References], repo: "Repo", path: PathLike) -> T_Refere
try:
instance: T_References
instance = ref_type(repo, path)
if instance.__class__ == SymbolicReference and instance.is_detached:
if instance.__class__ is SymbolicReference and instance.is_detached:
raise ValueError("SymbolicRef was detached, we drop it")
else:
return instance
Expand Down

0 comments on commit add46d9

Please sign in to comment.