Skip to content

Commit 3b273d4

Browse files
committed
style: remove f-string in log message
1 parent 4a81154 commit 3b273d4

21 files changed

Lines changed: 117 additions & 87 deletions

basilisk/config/account_config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def __init__(self, **data: Any):
148148
super().__init__(**data)
149149
except Exception as e:
150150
log.error(
151-
f"Error in account {e} the account will not be accessible",
151+
"Error in account '%s' the account will not be accessible",
152+
data.get("name", "Unknown"),
152153
exc_info=e,
153154
)
154155
raise e
@@ -404,7 +405,8 @@ def default_account(self) -> Account:
404405
account = self.get_account_from_info(self.default_account_info)
405406
if not account:
406407
log.warning(
407-
f"Default account not found for id {self.default_account_info} using the first account"
408+
"Default account not found for id %s using the first account",
409+
self.default_account_info,
408410
)
409411
account = self[0]
410412
return account
@@ -545,7 +547,10 @@ def add(self, account: Account):
545547
raise ValueError("Account must be an instance of Account")
546548
self.accounts.append(account)
547549
log.debug(
548-
f"Added account for {account.provider.name} ({account.name}, source: {account.source})"
550+
"Added account for %s (%s, source: %s)",
551+
account.provider.name,
552+
account.name,
553+
account.source,
549554
)
550555

551556
def get_accounts_by_provider(

basilisk/config/conversation_profile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def __init__(self, **data: Any):
6060
super().__init__(**data)
6161
except Exception as e:
6262
log.error(
63-
f"Error in conversation profile {e}; the profile will not be accessible",
63+
"Error in conversation profile '%s' the profile will not be accessible",
64+
data.get("name", "unknown"),
6465
exc_info=e,
6566
)
6667
raise e

basilisk/conversation/attached_file.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ def parse_supported_attachment_formats(
106106
for mime_type in sorted(supported_attachment_formats):
107107
exts = mimetypes.guess_all_extensions(mime_type)
108108
if exts:
109-
log.debug(f"Adding wildcard for MIME type {mime_type}: {exts}")
109+
log.debug("Adding wildcard for MIME type %s: %s", mime_type, exts)
110110
wildcard_parts.append("*" + ";*".join(exts))
111111
else:
112-
log.warning(f"No extensions found for MIME type {mime_type}")
112+
log.warning("No extensions found for MIME type %s", mime_type)
113113

114114
wildcard = ";".join(wildcard_parts)
115115
return wildcard
@@ -397,12 +397,12 @@ def remove_location(location: UPath):
397397
Args:
398398
location: The location of the file to remove.
399399
"""
400-
log.debug(f"Removing file at {location}")
400+
log.debug("Removing file at %s", location)
401401
try:
402402
fs = location.fs
403403
fs.rm(location.path)
404404
except Exception as e:
405-
log.error(f"Error deleting file at {location}: {e}")
405+
log.error("Error deleting file at '%s': %s", location, e)
406406

407407
def read_as_plain_text(self) -> str:
408408
"""Read the file as a plain text string.
@@ -531,7 +531,7 @@ def encode_base64(self) -> str:
531531
"""
532532
if self.size and self.size > 1024 * 1024 * 1024:
533533
log.warning(
534-
f"Large image ({self.display_size}) being encoded to base64"
534+
"Large image (%s) being encoded to base64", self.display_size
535535
)
536536
return super().encode_base64()
537537

basilisk/decorators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ def wrapper(*args, **kwargs):
6666
module_name = method.__module__
6767
qualname = method.__qualname__
6868
result = method(*args, **kwargs)
69+
exec_time = time.time() - start
6970
logger.debug(
70-
f"{module_name}.{qualname} took {time.time() - start:.3f} seconds"
71+
"%s.%s took %.3f seconds", module_name, qualname, exec_time
7172
)
7273
return result
7374

basilisk/file_watcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def on_modified(self, event: FileSystemEvent):
6060
elif event.src_path == OPEN_BSKC_FILE:
6161
self.on_open_bskc_file(event)
6262
else:
63-
logger.error(f"unknown event: {event}")
63+
logger.error("unknown event: %s", event)
6464

6565
def on_focus_file(self, event: FileSystemEvent):
6666
"""Handle modifications to the focus file with controlled event triggering.

basilisk/gui/account_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ def update_ui(self, event: wx.Event | None = None):
974974
event: The event that triggered the update. If None, the update was not triggered by an event.
975975
"""
976976
account = self.account_manager[self.account_list.GetFirstSelected()]
977-
log.debug(f"Selected account: {account}")
977+
log.debug("Selected account: %s", account)
978978
editable = account.source != AccountSource.ENV_VAR
979979
self.edit_btn.Enable(editable)
980980
self.remove_btn.Enable(editable)

basilisk/gui/conversation_tab.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def open_conversation(
119119
parent_window, "/path/to/conversation.json", "My Conversation"
120120
)
121121
"""
122-
log.debug(f"Opening conversation from {file_path}")
122+
log.debug("Opening conversation from %s", file_path)
123123
storage_path = cls.conv_storage_path()
124124
conversation = Conversation.open(file_path, storage_path)
125125
title = conversation.title or default_title
@@ -741,7 +741,7 @@ def add_attachments(self, paths: list[str | AttachmentFile | ImageFile]):
741741
Args:
742742
paths: List of attachment file paths
743743
"""
744-
log.debug(f"Adding attachments: {paths}")
744+
log.debug("Adding attachments: %s", paths)
745745
for path in paths:
746746
if isinstance(path, (AttachmentFile, ImageFile)):
747747
self.attachment_files.append(path)
@@ -1202,7 +1202,7 @@ def on_submit(self, event: wx.CommandEvent):
12021202
target=self._handle_completion, kwargs=completion_kw
12031203
)
12041204
self.task.start()
1205-
log.debug(f"Task {self.task.ident} started")
1205+
log.debug("Task %s started", self.task.ident)
12061206

12071207
def on_stop_completion(self, event: wx.CommandEvent):
12081208
"""Handle the stopping of the current completion task.
@@ -1262,7 +1262,8 @@ def _handle_completion(self, engine: BaseEngine, **kwargs: dict[str, Any]):
12621262
new_block.response.citations.append(chunk_data)
12631263
case _:
12641264
log.warning(
1265-
f"Unknown chunk type in streaming response: {chunk_type}"
1265+
"Unknown chunk type in streaming response: %s",
1266+
chunk_type,
12661267
)
12671268
wx.CallAfter(self._post_completion_with_stream, new_block)
12681269
else:
@@ -1345,7 +1346,7 @@ def _end_task(self, success: bool = True):
13451346
success: Whether the task completed successfully
13461347
"""
13471348
self.task.join()
1348-
log.debug(f"Task {self.task.ident} ended")
1349+
log.debug("Task %s ended", self.task.ident)
13491350
self.task = None
13501351
stop_sound()
13511352
if success:
@@ -1414,7 +1415,7 @@ def save_conversation(self, file_path: str) -> bool:
14141415
Returns:
14151416
True if the conversation was successfully saved, False otherwise.
14161417
"""
1417-
log.debug(f"Saving conversation to {file_path}")
1418+
log.debug("Saving conversation to %s", file_path)
14181419
try:
14191420
self.conversation.save(file_path)
14201421
return True

basilisk/gui/history_msg_text_ctrl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def handle_speech_stream_buffer(self, new_text: str = ''):
567567
# Concatenate new text to the buffer if no punctuation is found
568568
self.speech_stream_buffer += new_text
569569
except re.error as e:
570-
logger.error(f"Regex error in _handle_speech_stream_buffer: {e}")
570+
logger.error("Regex error in _handle_speech_stream_buffer: %s", e)
571571
# Fallback: treat the entire text as a single chunk
572572
self.speech_stream_buffer += new_text
573573

@@ -653,7 +653,7 @@ def _handle_citations(citations: list[dict[str, Any]]) -> str:
653653
case _:
654654
# Translators: This is a citation format for unknown locations
655655
location_text = _("Unknown location")
656-
logger.warning(f"Unknown citation type: {citation}")
656+
logger.warning("Unknown citation type: %s", citation)
657657
if document_index is not None:
658658
if document_title:
659659
location_text = _(

basilisk/gui/main_frame.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def on_hotkey(self, event):
300300
case HotkeyAction.CAPTURE_FULL:
301301
self.screen_capture(CaptureMode.FULL)
302302
case _:
303-
log.error(f"Unknown hotkey action: {event.GetId()}")
303+
log.error("Unknown hotkey action: %s", event.GetId())
304304

305305
def toggle_visibility(self, event):
306306
"""Toggle the visibility of the main application frame. If the frame is shown, it is minimized to the system tray. If it is hidden, it is restored.
@@ -334,7 +334,7 @@ def screen_capture(
334334
screen_coordinates: Coordinates for partial screen capture (left, top, width, height). Defaults to None.
335335
name: Custom name for the captured image. If not provided, a timestamp-based name is generated.
336336
"""
337-
log.debug(f"Capturing {capture_mode.value} screen")
337+
log.debug("Capturing %s screen", capture_mode.value)
338338
conv_tab = self.current_tab
339339
if not conv_tab:
340340
wx.MessageBox(
@@ -354,7 +354,7 @@ def screen_capture(
354354
conv_tab.conv_storage_path / f"attachments/{capture_name}"
355355
)
356356
name = name or capture_name
357-
log.debug(f"Capture file URL: {capture_path}")
357+
log.debug("Capture file URL: %s", capture_path)
358358
thread = ScreenCaptureThread(
359359
self,
360360
capture_path,
@@ -435,7 +435,7 @@ def on_quit(self, event: wx.Event | None):
435435
if tab.task:
436436
task_id = tab.task.ident
437437
log.debug(
438-
f"Waiting for conversation task {task_id} to finish..."
438+
"Waiting for conversation task %s to finish...", task_id
439439
)
440440
tab.task.join()
441441
log.debug("... is dead")
@@ -486,7 +486,8 @@ def on_new_default_conversation(self, event: wx.Event | None):
486486
profile = config.conversation_profiles().default_profile
487487
if profile:
488488
log.info(
489-
f"Creating a new conversation with default profile ({profile.name})"
489+
"Creating a new conversation with default profile (%s)",
490+
profile.name,
490491
)
491492
self.new_conversation(profile)
492493

@@ -523,7 +524,7 @@ def on_new_conversation(self, event: wx.Event):
523524
profile = self.get_selected_profile_from_menu(event)
524525
if not profile:
525526
return
526-
log.info(f"Creating a new conversation with profile: {profile.name}")
527+
log.info("Creating a new conversation with profile: %s", profile.name)
527528
self.new_conversation(profile)
528529

529530
def refresh_tab_title(self, include_frame: bool = False):
@@ -780,7 +781,7 @@ def on_install_nvda_addon(self, event):
780781
tmp_nvda_addon_path = os.path.join(
781782
tempfile.gettempdir(), "basiliskllm.nvda-addon"
782783
)
783-
log.debug(f"Creating NVDA addon: {tmp_nvda_addon_path}")
784+
log.debug("Creating NVDA addon: %s", tmp_nvda_addon_path)
784785
with zipfile.ZipFile(
785786
tmp_nvda_addon_path, 'w', zipfile.ZIP_DEFLATED
786787
) as zipf:
@@ -794,7 +795,7 @@ def on_install_nvda_addon(self, event):
794795
log.debug("NVDA addon created")
795796
os.startfile(tmp_nvda_addon_path)
796797
except Exception as e:
797-
log.error(f"Failed to create NVDA addon: {e}")
798+
log.error("Failed to create NVDA addon: %s", e)
798799
wx.MessageBox(
799800
_("Failed to create NVDA addon"),
800801
_("Error"),
@@ -847,7 +848,7 @@ def on_view_log(self, event: wx.Event | None):
847848
try:
848849
os.startfile(get_log_file_path())
849850
except Exception as e:
850-
log.error(f"Failed to open log file: {e}")
851+
log.error("Failed to open log file: %s", e)
851852
wx.MessageBox(
852853
_("Failed to open log file"), _("Error"), wx.OK | wx.ICON_ERROR
853854
)
@@ -884,7 +885,7 @@ def show_dialog():
884885
parent=self, title=_("New version available"), updater=updater
885886
)
886887
update_dialog.ShowModal()
887-
log.debug(f"Update dialog shown: {update_dialog.IsShown()}")
888+
log.debug("Update dialog shown: %s", update_dialog.IsShown())
888889

889890
wx.CallAfter(show_dialog)
890891

@@ -901,7 +902,7 @@ def show_dialog():
901902
parent=self, title=_("Downloading update"), updater=updater
902903
)
903904
download_dialog.ShowModal()
904-
log.debug(f"Download dialog shown: {download_dialog.IsShown()}")
905+
log.debug("Download dialog shown: %s", download_dialog.IsShown())
905906

906907
wx.CallAfter(show_dialog)
907908

@@ -1005,7 +1006,7 @@ def on_apply_conversation_profile(self, event: wx.Event):
10051006
profile = self.get_selected_profile_from_menu(event)
10061007
if not profile:
10071008
return
1008-
log.info(f"Applying profile: {profile.name} to conversation")
1009+
log.info("Applying profile: %s to conversation", profile.name)
10091010
self.current_tab.apply_profile(profile)
10101011

10111012
def handle_no_account_configured(self):
@@ -1104,7 +1105,9 @@ def open_conversation(self, file_path: str):
11041105
style=wx.OK | wx.ICON_ERROR,
11051106
)
11061107
log.error(
1107-
f"Failed to open conversation file: {file_path}, error: {e}",
1108+
"Failed to open conversation file: %s, error: %s",
1109+
file_path,
1110+
e,
11081111
exc_info=e,
11091112
)
11101113

basilisk/gui/ocr_handler.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ def _handle_ocr_message(
8585
self._handle_ocr_completion_message(message_type, data, dialog)
8686
else:
8787
log.warning(
88-
f"Unknown message type in result queue: {message_type}"
88+
"Unknown message type in result queue: %s", message_type
8989
)
9090
except Exception as e:
91-
log.error(f"Error handling message: {str(e)}", exc_info=True)
91+
log.error("Error handling message: %s", e, exc_info=True)
9292
wx.MessageBox(
93-
_("An error occurred while processing OCR results. Details:")
94-
+ f"\n{e}",
93+
_(
94+
"An error occurred while processing OCR results. Details: \n%s"
95+
)
96+
% e,
9597
_("Error"),
9698
wx.OK | wx.ICON_ERROR,
9799
)
@@ -167,7 +169,9 @@ def _display_ocr_result(self, data: Any) -> None:
167169
wx.MessageBox(data, _("Result"), wx.OK | wx.ICON_INFORMATION)
168170
else:
169171
log.warning(
170-
f"Unexpected OCR result data type or empty result: {type(data).__name__} - {data}"
172+
"Unexpected OCR result data type or empty result: %s - %s",
173+
type(data),
174+
data,
171175
)
172176
wx.MessageBox(
173177
_("OCR completed, but no text was extracted."),
@@ -213,13 +217,13 @@ def _cleanup_ocr_process(self, dialog: ProgressBarDialog) -> None:
213217
log.warning("Process did not terminate, killing it")
214218
self.process.kill()
215219
except Exception as e:
216-
log.error(f"Error terminating process: {str(e)}", exc_info=True)
220+
log.error("Error terminating process: %", e, exc_info=True)
217221

218222
try:
219223
if dialog and dialog.IsShown():
220224
dialog.Destroy()
221225
except Exception as e:
222-
log.error(f"Error destroying dialog: {str(e)}", exc_info=True)
226+
log.error("Error destroying dialog: %s", e, exc_info=True)
223227

224228
self.ocr_button.Enable()
225229
self.process = None

0 commit comments

Comments
 (0)