Cleanup: quiet Python warnings from ruff
This commit is contained in:
@@ -197,8 +197,8 @@ def write(output):
|
||||
|
||||
glext = sorted(gpu.capabilities.extensions_get())
|
||||
|
||||
for l in glext:
|
||||
output.write("\t{:s}\n".format(l))
|
||||
for line in glext:
|
||||
output.write("\t{:s}\n".format(line))
|
||||
|
||||
output.write(title("Implementation Dependent GPU Limits"))
|
||||
output.write("Maximum Batch Vertices:\t{:d}\n".format(
|
||||
|
||||
@@ -114,22 +114,22 @@ def _fake_module(mod_name, mod_path, speedy=True):
|
||||
if speedy:
|
||||
lines = []
|
||||
line_iter = iter(file_mod)
|
||||
l = ""
|
||||
while not l.startswith("bl_info"):
|
||||
line = ""
|
||||
while not line.startswith("bl_info"):
|
||||
try:
|
||||
l = line_iter.readline()
|
||||
line = line_iter.readline()
|
||||
except UnicodeDecodeError as ex:
|
||||
if not error_encoding:
|
||||
error_encoding = True
|
||||
print("Error reading file as UTF-8:", mod_path, ex)
|
||||
return None
|
||||
|
||||
if len(l) == 0:
|
||||
if len(line) == 0:
|
||||
break
|
||||
while l.rstrip():
|
||||
lines.append(l)
|
||||
while line.rstrip():
|
||||
lines.append(line)
|
||||
try:
|
||||
l = line_iter.readline()
|
||||
line = line_iter.readline()
|
||||
except UnicodeDecodeError as ex:
|
||||
if not error_encoding:
|
||||
error_encoding = True
|
||||
|
||||
@@ -102,11 +102,12 @@ class DataPathBuilder:
|
||||
|
||||
|
||||
def id_iter():
|
||||
type_iter = type(bpy.data.objects)
|
||||
from bpy.types import bpy_prop_collection
|
||||
assert isinstance(bpy.data.objects, bpy_prop_collection)
|
||||
|
||||
for attr in dir(bpy.data):
|
||||
data_iter = getattr(bpy.data, attr, None)
|
||||
if type(data_iter) == type_iter:
|
||||
if isinstance(data_iter, bpy_prop_collection):
|
||||
for id_data in data_iter:
|
||||
if id_data.library is None:
|
||||
yield id_data
|
||||
|
||||
@@ -867,11 +867,11 @@ def dump_src_messages(msgs, reports, settings):
|
||||
forced = set()
|
||||
if os.path.isfile(settings.SRC_POTFILES):
|
||||
with open(settings.SRC_POTFILES, encoding="utf8") as src:
|
||||
for l in src:
|
||||
if l[0] == '-':
|
||||
forbidden.add(l[1:].rstrip('\n'))
|
||||
elif l[0] != '#':
|
||||
forced.add(l.rstrip('\n'))
|
||||
for line in src:
|
||||
if line[0] == '-':
|
||||
forbidden.add(line[1:].rstrip('\n'))
|
||||
elif line[0] != '#':
|
||||
forced.add(line.rstrip('\n'))
|
||||
for root, dirs, files in os.walk(settings.POTFILES_SOURCE_DIR):
|
||||
if "/.git" in root:
|
||||
continue
|
||||
|
||||
@@ -187,7 +187,7 @@ clean_name._trans_cache = {}
|
||||
|
||||
|
||||
def _clean_utf8(name):
|
||||
if type(name) == bytes:
|
||||
if type(name) is bytes:
|
||||
return name.decode("utf8", "replace")
|
||||
else:
|
||||
return name.encode("utf8", "replace").decode("utf8")
|
||||
|
||||
@@ -33,8 +33,11 @@ class _TempModuleOverride:
|
||||
|
||||
|
||||
def add_scrollback(text, text_type):
|
||||
for l in text.split("\n"):
|
||||
bpy.ops.console.scrollback_append(text=l, type=text_type)
|
||||
for line in text.split("\n"):
|
||||
bpy.ops.console.scrollback_append(
|
||||
text=line,
|
||||
type=text_type,
|
||||
)
|
||||
|
||||
|
||||
def replace_help(namespace):
|
||||
|
||||
@@ -9,9 +9,11 @@ language_id = "shell"
|
||||
|
||||
|
||||
def add_scrollback(text, text_type):
|
||||
for l in text.split("\n"):
|
||||
bpy.ops.console.scrollback_append(text=l.replace("\t", " "),
|
||||
type=text_type)
|
||||
for line in text.split("\n"):
|
||||
bpy.ops.console.scrollback_append(
|
||||
text=line.replace("\t", " "),
|
||||
type=text_type,
|
||||
)
|
||||
|
||||
|
||||
def shell_run(text):
|
||||
|
||||
@@ -57,9 +57,10 @@ def graph_armature(obj, filepath, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=Tr
|
||||
if key.startswith("_"):
|
||||
continue
|
||||
|
||||
if type(value) == float:
|
||||
value_type = type(value)
|
||||
if value_type is float:
|
||||
value = "{:.3f}".format(value)
|
||||
elif type(value) == str:
|
||||
elif value_type is str:
|
||||
value = compat_str(value)
|
||||
|
||||
label.append("{:s} = {:s}".format(key, value))
|
||||
|
||||
@@ -229,7 +229,7 @@ class DATA_PT_geometry_curve_start_end(CurveButtonsPanelCurve, Panel):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
# Text objects don't support these properties
|
||||
return (type(context.curve) == Curve)
|
||||
return (type(context.curve) is Curve)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -43,7 +43,7 @@ def _keymap_fn_from_seq(keymap_data):
|
||||
|
||||
|
||||
def _item_is_fn(item):
|
||||
return (not (type(item) is ToolDef) and callable(item))
|
||||
return ((type(item) is not ToolDef) and callable(item))
|
||||
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -2432,8 +2432,8 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
|
||||
sub = box.row()
|
||||
sub.label(text=lines[0])
|
||||
sub.label(icon='ERROR')
|
||||
for l in lines[1:]:
|
||||
box.label(text=l)
|
||||
for line in lines[1:]:
|
||||
box.label(text=line)
|
||||
|
||||
@staticmethod
|
||||
def _draw_addon_header(layout, prefs, wm):
|
||||
|
||||
Reference in New Issue
Block a user