From 17a460d0b15c3312a314ab39a50b1e1c83a0c266 Mon Sep 17 00:00:00 2001 From: Benjamin Auquite Date: Wed, 13 Mar 2024 05:42:09 -0500 Subject: [PATCH] run `ruff check . --fix` --- .../pykotor/resource/formats/lip/lip_data.py | 2 +- .../pykotor/resource/formats/tpc/tpc_auto.py | 1 + .../PyKotor/src/pykotor/tools/registry.py | 2 +- .../PyKotorGL/src/pykotor/gl/models/mdl.py | 2 +- Libraries/Utility/src/utility/string.py | 18 +++++++++--------- Tools/HoloPatcher/src/__main__.py | 2 +- .../src/toolset/gui/windows/main.py | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Libraries/PyKotor/src/pykotor/resource/formats/lip/lip_data.py b/Libraries/PyKotor/src/pykotor/resource/formats/lip/lip_data.py index c0b3a5e1f..f350f3238 100644 --- a/Libraries/PyKotor/src/pykotor/resource/formats/lip/lip_data.py +++ b/Libraries/PyKotor/src/pykotor/resource/formats/lip/lip_data.py @@ -120,7 +120,7 @@ def compare(self, other: LIP, log_func=print) -> bool: return ret -# mapping in LipSyncEditor is not very accurate. for example, shape 0 is neutral, not EE, +# mapping in LipSyncEditor is not very accurate. for example, shape 0 is neutral, not EE, # meaning pauses are not properly represented when using LipSyncEditor. shape 15 is too open to be KG and etc. # https://imgur.com/a/LIRZ8B1 class LIPShape(IntEnum): diff --git a/Libraries/PyKotor/src/pykotor/resource/formats/tpc/tpc_auto.py b/Libraries/PyKotor/src/pykotor/resource/formats/tpc/tpc_auto.py index 1355ce3ac..97fa39b72 100644 --- a/Libraries/PyKotor/src/pykotor/resource/formats/tpc/tpc_auto.py +++ b/Libraries/PyKotor/src/pykotor/resource/formats/tpc/tpc_auto.py @@ -1,4 +1,5 @@ from __future__ import annotations + import os from typing import TYPE_CHECKING diff --git a/Libraries/PyKotor/src/pykotor/tools/registry.py b/Libraries/PyKotor/src/pykotor/tools/registry.py index c758a19d9..1291148b5 100644 --- a/Libraries/PyKotor/src/pykotor/tools/registry.py +++ b/Libraries/PyKotor/src/pykotor/tools/registry.py @@ -208,7 +208,7 @@ def create_registry_path(hive, path): # sourcery skip: raise-from-previous-erro try: winreg.CreateKey(hive, current_path) except PermissionError: - raise PermissionError(f"Permission denied. Administrator privileges required.") from e # noqa: B904, TRY003, EM101 + raise PermissionError("Permission denied. Administrator privileges required.") from e # noqa: B904, TRY003, EM101 except Exception as e: # pylint: disable=W0718 # noqa: BLE001 # sourcery skip: raise-specific-error raise Exception(f"Failed to create registry key: {current_path}. Error: {e}") # noqa: TRY002, TRY003, EM102, B904 diff --git a/Libraries/PyKotorGL/src/pykotor/gl/models/mdl.py b/Libraries/PyKotorGL/src/pykotor/gl/models/mdl.py index c89c4aace..78df97ae8 100644 --- a/Libraries/PyKotorGL/src/pykotor/gl/models/mdl.py +++ b/Libraries/PyKotorGL/src/pykotor/gl/models/mdl.py @@ -211,7 +211,7 @@ def draw(self, shader: Shader, transform: mat4, override_texture: str | None = N if self.mesh and self.render: self.mesh.draw(shader, transform, override_texture) - for child in self.children: + for child in self.children: child.draw(shader, transform, override_texture=override_texture) diff --git a/Libraries/Utility/src/utility/string.py b/Libraries/Utility/src/utility/string.py index df9d4b91f..5209d6d5d 100644 --- a/Libraries/Utility/src/utility/string.py +++ b/Libraries/Utility/src/utility/string.py @@ -11,21 +11,21 @@ from typing_extensions import LiteralString, Self, SupportsIndex def insert_newlines(text: str, length: int = 100) -> str: - words = text.split(' ') - new_string = '' - current_line = '' - + words = text.split(" ") + new_string = "" + current_line = "" + for word in words: if len(current_line) + len(word) + 1 <= length: - current_line += word + ' ' + current_line += word + " " else: - new_string += current_line.rstrip() + '\n' - current_line = word + ' ' - + new_string += current_line.rstrip() + "\n" + current_line = word + " " + # Add the last line if there's any content left. if current_line: new_string += current_line.rstrip() - + return new_string def ireplace(original: str, target: str, replacement: str) -> str: diff --git a/Tools/HoloPatcher/src/__main__.py b/Tools/HoloPatcher/src/__main__.py index f1d7823d7..08e4d077e 100644 --- a/Tools/HoloPatcher/src/__main__.py +++ b/Tools/HoloPatcher/src/__main__.py @@ -152,7 +152,7 @@ def parse_args() -> Namespace: return kwargs -class App(): +class App: def __init__(self): self.root = tk.Tk() self.root.title(f"HoloPatcher {VERSION_LABEL}") diff --git a/Tools/HolocronToolset/src/toolset/gui/windows/main.py b/Tools/HolocronToolset/src/toolset/gui/windows/main.py index 4b437392e..b239198c1 100644 --- a/Tools/HolocronToolset/src/toolset/gui/windows/main.py +++ b/Tools/HolocronToolset/src/toolset/gui/windows/main.py @@ -763,7 +763,7 @@ def refreshOverrideList(self, *, reload=True): """Refreshes the list of override directories in the overrideFolderCombo combobox.""" if self.active is None: print("no installation is currently loaded, cannot refresh override list") - return None + return if reload: self.active.load_override()