Skip to content

Commit

Permalink
fix flake8 error (#646)
Browse files Browse the repository at this point in the history
This checks the type of variables via isinstance instead of type ==, allowing for inheritance and making tox happy
  • Loading branch information
diohe0311 committed Jul 31, 2023
1 parent a681252 commit 6690c96
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions providers/base/bin/accelerometer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def direction_poll(self, x_axis, y_axis):
for mapping, data in direction_map.items():
reading = self.parse_reading(int(data), mapping)

if type(reading) == int:
if isinstance(reading, int):
return reading, mapping

# Return nothing if threshold is not met
Expand All @@ -180,7 +180,7 @@ def run(self):
while len(rem_tests) > 0:
axis_data_bundle = self.grab_current_readings()

if type(axis_data_bundle) != list:
if not isinstance(axis_data_bundle, list):
logging.error("Failed to grab appropriate readings")
return 1

Expand Down
2 changes: 1 addition & 1 deletion providers/base/bin/hotkey_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def press_key(self, key_code, modifiers=set(), repetitions=1, delay=0.05):
while repetitions:
if not modifiers.issubset({'alt', 'ctrl', 'shift', 'meta'}):
raise SystemExit('Unknown modifier')
if type(key_code) == KeyCodes:
if isinstance(key_code, KeyCodes):
key_code = key_code.value
data = bytes()
data += self.event_struct.pack(0, 0, 4, 4, key_code)
Expand Down
2 changes: 1 addition & 1 deletion providers/base/bin/key_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def on_key(self, source, cb_condition):
# Check for ESC key pressed
self.show_text(_("Test cancelled"))
self.quit()
elif 1 < code < 10 and type(self) == CLIReporter:
elif 1 < code < 10 and isinstance(self, CLIReporter):
# Check for number to skip
self.toggle_key(self.keys[code - 2])
else:
Expand Down

0 comments on commit 6690c96

Please sign in to comment.