Skip to content

Commit

Permalink
refactor: merge isinstance calls
Browse files Browse the repository at this point in the history
You can pass a tuple of types you want to check as the second argument to `isinstance`. If the object matches with any of the types, it will return `True` else `False`.
  • Loading branch information
deepsource-autofix[bot] authored Nov 14, 2024
1 parent 6c791bf commit 66c90b2
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions python/demo_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ def tar_something():
def bad_isinstance(initial_condition, object, other_obj, foo, bar, baz):
if (
initial_condition
and (
isinstance(object, int)
or isinstance(object, float)
or isinstance(object, str)
)
and isinstance(object, (int, float, str))
and isinstance(other_obj, float)
and isinstance(foo, str)
or (isinstance(bar, float) or isinstance(bar, str))
Expand Down

0 comments on commit 66c90b2

Please sign in to comment.