Skip to content

Update type comparison #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Xlib/ext/nvcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 9 additions & 9 deletions Xlib/protocol/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions Xlib/protocol/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)]

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Xlib/rdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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

Expand Down
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