ruff fix但指定了--unsafe-fixes

This commit is contained in:
minecraft1024a
2025-10-05 21:48:32 +08:00
committed by Windpicker-owo
parent 04feb585b4
commit 2a89efe47a
76 changed files with 301 additions and 316 deletions

View File

@@ -96,16 +96,16 @@ def compare_dicts(new, old, path=None, logs=None):
continue
if key not in old:
comment = get_key_comment(new, key)
logs.append(f"新增: {'.'.join(path + [str(key)])} 注释: {comment or ''}")
elif isinstance(new[key], (dict, Table)) and isinstance(old.get(key), (dict, Table)):
compare_dicts(new[key], old[key], path + [str(key)], logs)
logs.append(f"新增: {'.'.join([*path, str(key)])} 注释: {comment or ''}")
elif isinstance(new[key], dict | Table) and isinstance(old.get(key), dict | Table):
compare_dicts(new[key], old[key], [*path, str(key)], logs)
# 删减项
for key in old:
if key == "version":
continue
if key not in new:
comment = get_key_comment(old, key)
logs.append(f"删减: {'.'.join(path + [str(key)])} 注释: {comment or ''}")
logs.append(f"删减: {'.'.join([*path, str(key)])} 注释: {comment or ''}")
return logs
@@ -145,11 +145,11 @@ def compare_default_values(new, old, path=None, logs=None, changes=None):
if key == "version":
continue
if key in old:
if isinstance(new[key], (dict, Table)) and isinstance(old[key], (dict, Table)):
compare_default_values(new[key], old[key], path + [str(key)], logs, changes)
if isinstance(new[key], dict | Table) and isinstance(old[key], dict | Table):
compare_default_values(new[key], old[key], [*path, str(key)], logs, changes)
elif new[key] != old[key]:
logs.append(f"默认值变化: {'.'.join(path + [str(key)])} 旧默认值: {old[key]} 新默认值: {new[key]}")
changes.append((path + [str(key)], old[key], new[key]))
logs.append(f"默认值变化: {'.'.join([*path, str(key)])} 旧默认值: {old[key]} 新默认值: {new[key]}")
changes.append(([*path, str(key)], old[key], new[key]))
return logs, changes
@@ -179,7 +179,7 @@ def _remove_obsolete_keys(target: TOMLDocument | dict | Table, reference: TOMLDo
for key in list(target.keys()):
if key not in reference:
del target[key]
elif isinstance(target.get(key), (dict, Table)) and isinstance(reference.get(key), (dict, Table)):
elif isinstance(target.get(key), dict | Table) and isinstance(reference.get(key), dict | Table):
_remove_obsolete_keys(target[key], reference[key])
@@ -197,7 +197,7 @@ def _update_dict(target: TOMLDocument | dict | Table, source: TOMLDocument | dic
if key in target:
# 键已存在,更新值
target_value = target[key]
if isinstance(value, dict) and isinstance(target_value, (dict, Table)):
if isinstance(value, dict) and isinstance(target_value, dict | Table):
_update_dict(target_value, value)
else:
try: