diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 7a21826..637c720 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -302,7 +302,7 @@ def get_cooler_manual_control_enabled(self, target): def set_cooler_manual_control_enabled(self, target, enabled): - return set_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 + return set_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) def get_fan_duty(self, target): diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 0d910da..ee5bef0 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -326,13 +326,13 @@ def get_extension_major(self, extname): return self.extension_major_opcodes[extname] def add_extension_event(self, code, evt, subcode=None): - if subcode == None: - self.event_classes[code] = evt - else: - if not code in self.event_classes: - self.event_classes[code] = {subcode: evt} - else: - self.event_classes[code][subcode] = evt + if subcode is None: + self.event_classes[code] = evt + else: + if not code in self.event_classes: + self.event_classes[code] = {subcode: evt} + else: + self.event_classes[code][subcode] = evt def add_extension_error(self, code, err): self.error_classes[code] = err @@ -820,11 +820,11 @@ def parse_event_response(self, etype): length = 32 estruct = self.event_classes.get(etype, event.AnyEvent) - if type(estruct) == dict: + if isinstance(estruct, dict): subcode = self.data_recv[1] # Python2 compatibility - if type(subcode) == str: + if isinstance(subcode, str): subcode = ord(subcode) # this etype refers to a set of sub-events with individual subcodes diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 8bc8205..1b6c491 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -295,10 +295,7 @@ def __init__(self, name, codes = (), default = None): self.codes = codes def check_value(self, value): - if hasattr(value, self.cast_function): - return getattr(value, self.cast_function)() - else: - return value + return getattr(value, self.cast_function, lambda: value)() def parse_value(self, value, display): # if not display: @@ -860,7 +857,7 @@ def parse_binary_value(self, data, display, length, format): from . import event estruct = display.event_classes.get(byte2int(data) & 0x7f, event.AnyEvent) - if type(estruct) == dict: + if isinstance(estruct, dict): # this etype refers to a set of sub-events with individual subcodes estruct = estruct[indexbytes(data, 1)] @@ -1078,7 +1075,7 @@ def pack_value(self, value): """ - if type(value) is tuple: + if isinstance(value, tuple): return self.to_binary(*value) elif isinstance(value, dict): return self.to_binary(**value) @@ -1220,7 +1217,7 @@ def pack_value(self, value): for v in value: # Let values be simple strings, meaning a delta of 0 - if type(v) in (str, bytes): + if isinstance(v, (str, bytes)): v = (0, v) # A tuple, it should be (delta, string) diff --git a/Xlib/rdb.py b/Xlib/rdb.py index 03b06e2..93d4cdd 100644 --- a/Xlib/rdb.py +++ b/Xlib/rdb.py @@ -70,7 +70,7 @@ def insert_file(self, file): """ - if type(file) is bytes: + if isinstance(file, bytes): file = open(file, 'r') self.insert_string(file.read()) @@ -382,7 +382,7 @@ class _Match(object): def __init__(self, path, dbs): self.path = path - if type(dbs) is tuple: + if isinstance(dbs, tuple): self.skip = 0 self.group = dbs pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy