forked from drath/libratbag
Use 'key in dict' instead of 'key in dict.keys()'
This commit is contained in:
@@ -20,6 +20,9 @@ select = [
|
||||
# pep8-naming
|
||||
# `Error` suffix on exception names.
|
||||
"N818",
|
||||
# flake8-simplify
|
||||
# Use 'key in dict' instead of 'key in dict.keys()'.
|
||||
"SIM118",
|
||||
]
|
||||
ignore = [
|
||||
# Line too long.
|
||||
|
||||
@@ -72,7 +72,7 @@ def check_devicetype_str(string):
|
||||
def check_section_device(section: configparser.SectionProxy):
|
||||
required_keys = ["Name", "Driver", "DeviceMatch", "DeviceType"]
|
||||
|
||||
for key in section.keys():
|
||||
for key in section:
|
||||
assertIn(key, required_keys)
|
||||
|
||||
for r in required_keys:
|
||||
@@ -131,7 +131,7 @@ def check_section_asus(section: configparser.SectionProxy):
|
||||
"Quirks",
|
||||
"Wireless",
|
||||
)
|
||||
for key in section.keys():
|
||||
for key in section:
|
||||
assertIn(key, permitted_keys)
|
||||
|
||||
try:
|
||||
@@ -161,7 +161,7 @@ def check_section_hidpp10(section: configparser.SectionProxy):
|
||||
"DeviceIndex",
|
||||
"Leds",
|
||||
]
|
||||
for key in section.keys():
|
||||
for key in section:
|
||||
assertIn(key, permitted)
|
||||
|
||||
try:
|
||||
@@ -210,7 +210,7 @@ def check_section_hidpp10(section: configparser.SectionProxy):
|
||||
|
||||
def check_section_hidpp20(section: configparser.SectionProxy):
|
||||
permitted = ["Buttons", "DeviceIndex", "Leds", "ReportRate", "Quirk"]
|
||||
for key in section.keys():
|
||||
for key in section:
|
||||
assertIn(key, permitted)
|
||||
|
||||
try:
|
||||
@@ -231,7 +231,7 @@ def check_section_steelseries(section: configparser.SectionProxy):
|
||||
"MacroLength",
|
||||
"Quirk",
|
||||
)
|
||||
for key in section.keys():
|
||||
for key in section:
|
||||
assertIn(key, permitted_keys)
|
||||
|
||||
try:
|
||||
|
||||
@@ -43,7 +43,7 @@ class MetaRatbag(type):
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
for k in libratbag.__dict__.keys():
|
||||
for k in libratbag.__dict__:
|
||||
if k.startswith(prefix) and k.isupper():
|
||||
key = k[len(prefix) :]
|
||||
dct[key] = getattr(libratbag, k)
|
||||
@@ -215,7 +215,7 @@ class Ratbagd:
|
||||
else:
|
||||
self._devices[id] = dev
|
||||
|
||||
return self._devices[id] if id in self._devices.keys() else None
|
||||
return self._devices[id] if id in self._devices else None
|
||||
|
||||
def set_verbose(self, verbose):
|
||||
if verbose > 2:
|
||||
@@ -230,7 +230,7 @@ class Ratbagd:
|
||||
|
||||
def get_capabilities(type, object):
|
||||
capabilities = []
|
||||
for k in libratbag.__dict__.keys():
|
||||
for k in libratbag.__dict__:
|
||||
if k.startswith(f"RATBAG_{type.upper()}_CAP_") and "CAP_NONE" not in k:
|
||||
cap = getattr(libratbag, k)
|
||||
func = getattr(libratbag, f"ratbag_{type.lower()}_has_capability")
|
||||
|
||||
@@ -282,7 +282,7 @@ class Ratbagd(_RatbagdDBus):
|
||||
self.emit("daemon-disappeared")
|
||||
|
||||
def _on_properties_changed(self, proxy, changed_props, invalidated_props):
|
||||
if "Devices" in changed_props.keys():
|
||||
if "Devices" in changed_props:
|
||||
object_paths = [d._object_path for d in self._devices]
|
||||
for object_path in changed_props["Devices"]:
|
||||
if object_path not in object_paths:
|
||||
@@ -452,14 +452,14 @@ class RatbagdProfile(_RatbagdDBus):
|
||||
self.notify("dirty")
|
||||
|
||||
def _on_properties_changed(self, proxy, changed_props, invalidated_props):
|
||||
if "IsActive" in changed_props.keys():
|
||||
if "IsActive" in changed_props:
|
||||
active = changed_props["IsActive"]
|
||||
if active != self._active:
|
||||
self._active = active
|
||||
self.notify("is-active")
|
||||
self._on_obj_notify(None, None)
|
||||
|
||||
if "ReportRate" in changed_props.keys():
|
||||
if "ReportRate" in changed_props:
|
||||
report_rate = changed_props["ReportRate"]
|
||||
if report_rate != self._report_rate:
|
||||
self._report_rate = report_rate
|
||||
@@ -619,19 +619,19 @@ class RatbagdResolution(_RatbagdDBus):
|
||||
self._disabled = self._get_dbus_property("IsDisabled")
|
||||
|
||||
def _on_properties_changed(self, proxy, changed_props, invalidated_props):
|
||||
if "IsActive" in changed_props.keys():
|
||||
if "IsActive" in changed_props:
|
||||
active = changed_props["IsActive"]
|
||||
if active != self._active:
|
||||
self._active = active
|
||||
self.notify("is-active")
|
||||
|
||||
if "IsDefault" in changed_props.keys():
|
||||
if "IsDefault" in changed_props:
|
||||
default = changed_props["IsDefault"]
|
||||
if default != self._default:
|
||||
self._default = default
|
||||
self.notify("is-default")
|
||||
|
||||
if "IsDisabled" in changed_props.keys():
|
||||
if "IsDisabled" in changed_props:
|
||||
disabled = changed_props["IsDisabled"]
|
||||
if disabled != self._disabled:
|
||||
self._disabled = disabled
|
||||
@@ -792,7 +792,7 @@ class RatbagdButton(_RatbagdDBus):
|
||||
super().__init__("Button", object_path)
|
||||
|
||||
def _on_properties_changed(self, proxy, changed_props, invalidated_props):
|
||||
if "Mapping" in changed_props.keys():
|
||||
if "Mapping" in changed_props:
|
||||
self.notify("action-type")
|
||||
|
||||
def _mapping(self):
|
||||
|
||||
Reference in New Issue
Block a user