Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

chore(ruff): defer logging conversions (#10885)

Shahmir Varqha0c697a2bbf2f
diff --git a/marimo/_ai/_tools/tools/rules.py b/marimo/_ai/_tools/tools/rules.py
index bb470da385..6de925fd35 100644
--- a/marimo/_ai/_tools/tools/rules.py
+++ b/marimo/_ai/_tools/tools/rules.py
@@ -57,7 +57,7 @@ class GetMarimoRules(ToolBase[EmptyArgs, GetMarimoRulesOutput]):
LOGGER.warning(
"Failed to read bundled marimo rules from %s: %s",
MARIMO_RULES_PATH,
- str(e),
+ e,
)
# Fall through to fetch from URL
@@ -78,7 +78,7 @@ class GetMarimoRules(ToolBase[EmptyArgs, GetMarimoRulesOutput]):
LOGGER.warning(
"Failed to fetch marimo rules from %s: %s",
MARIMO_RULES_URL,
- str(e),
+ e,
)
return GetMarimoRulesOutput(
diff --git a/marimo/_config/manager.py b/marimo/_config/manager.py
index dbbf362243..2e48911597 100644
--- a/marimo/_config/manager.py
+++ b/marimo/_config/manager.py
@@ -523,7 +523,7 @@ class UserConfigManager(MarimoConfigReader):
except OSError as e:
path = None
LOGGER.warning(
- "Encountered error when searching for config: %s", str(e)
+ "Encountered error when searching for config: %s", e
)
if path is not None:
diff --git a/marimo/_config/utils.py b/marimo/_config/utils.py
index 5dbde45b07..b3a2abed25 100644
--- a/marimo/_config/utils.py
+++ b/marimo/_config/utils.py
@@ -49,7 +49,7 @@ def get_or_create_user_config_path() -> str:
LOGGER.error(
"Could not search for config file due to path error: %s. "
"Falling back to XDG config path.",
- str(e),
+ e,
)
# No config found or error occurred, create XDG config
diff --git a/marimo/_messaging/notification.py b/marimo/_messaging/notification.py
index 8a8f6ff46e..72f66c066c 100644
--- a/marimo/_messaging/notification.py
+++ b/marimo/_messaging/notification.py
@@ -132,7 +132,7 @@ class CellNotification(Notification, tag="cell-op"):
# The context variable hasn't been set yet
self.run_id = None
except Exception as e:
- LOGGER.error("Error getting run id: %s", str(e))
+ LOGGER.error("Error getting run id: %s", e)
self.run_id = None
diff --git a/marimo/_output/formatting.py b/marimo/_output/formatting.py
index 5cfc911cc0..59b7c69d72 100644
--- a/marimo/_output/formatting.py
+++ b/marimo/_output/formatting.py
@@ -72,7 +72,7 @@ class FormatterRegistry:
except BaseException as e:
# Some exotic metaclasses or broken types may raise when calling mro
LOGGER.warning(
- "Failed to read MRO for type %s: %s", top_level_type, str(e)
+ "Failed to read MRO for type %s: %s", top_level_type, e
)
return None
diff --git a/marimo/_runtime/complete.py b/marimo/_runtime/complete.py
index e5b83840f2..e604a93095 100644
--- a/marimo/_runtime/complete.py
+++ b/marimo/_runtime/complete.py
@@ -334,7 +334,7 @@ def _get_completion_info(completion: jedi.api.classes.BaseName) -> str:
return _get_type_hint(completion)
return _get_docstring(completion)
except Exception as e:
- LOGGER.debug("jedi failed to get completion info: %s", str(e))
+ LOGGER.debug("jedi failed to get completion info: %s", e)
return ""
@@ -643,7 +643,7 @@ def _get_completions(
# jedi's static analysis can crash while inferring some code — for
# example https://github.com/davidhalter/jedi/issues/1990).
# Fallback to interpreter when it crashes
- LOGGER.debug("Completion with jedi Script failed: %s", str(e))
+ LOGGER.debug("Completion with jedi Script failed: %s", e)
return _get_completions_with_interpreter(document, glbls, glbls_lock)
diff --git a/marimo/_runtime/runner/cell_runner.py b/marimo/_runtime/runner/cell_runner.py
index 53b73f48b2..22f936fc66 100644
--- a/marimo/_runtime/runner/cell_runner.py
+++ b/marimo/_runtime/runner/cell_runner.py
@@ -579,7 +579,7 @@ class Runner:
as sample code to reproduce, will help us debug.
%s
""",
- str(unexpected_failure),
+ unexpected_failure,
)
# Mark as interrupted if the cell raised a MarimoInterrupt
@@ -719,7 +719,7 @@ class Runner:
An exception raised attempting to continue debugger (%s).
""",
- str(debugger_error),
+ debugger_error,
)
def _get_blamed_cell(
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.py
index 9c13515dbe..486b4f45d6 100644
--- a/marimo/_runtime/runtime.py
+++ b/marimo/_runtime/runtime.py
@@ -1078,9 +1078,7 @@ class Kernel:
try:
duckdb.execute(f"DROP TABLE IF EXISTS {qualified}")
except Exception as e:
- LOGGER.warning(
- "Failed to drop table %s: %s", name, str(e)
- )
+ LOGGER.warning("Failed to drop table %s: %s", name, e)
elif variable.kind == "view" and DependencyManager.duckdb.has():
import duckdb
@@ -1092,9 +1090,7 @@ class Kernel:
try:
duckdb.execute(f"DROP VIEW IF EXISTS {qualified}")
except Exception as e:
- LOGGER.warning(
- "Failed to drop view %s: %s", name, str(e)
- )
+ LOGGER.warning("Failed to drop view %s: %s", name, e)
elif variable.kind == "catalog" and DependencyManager.duckdb.has():
import duckdb
@@ -1102,9 +1098,7 @@ class Kernel:
identifier = quote_sql_identifier(name)
duckdb.execute(f"DETACH DATABASE IF EXISTS {identifier}")
except Exception as e:
- LOGGER.warning(
- "Failed to detach catalog %s: %s", name, str(e)
- )
+ LOGGER.warning("Failed to detach catalog %s: %s", name, e)
else:
if name in self.globals:
del self.globals[name]
diff --git a/marimo/_server/api/endpoints/ai.py b/marimo/_server/api/endpoints/ai.py
index bf6bc5912a..0ec3da2ba7 100644
--- a/marimo/_server/api/endpoints/ai.py
+++ b/marimo/_server/api/endpoints/ai.py
@@ -349,7 +349,7 @@ async def ai_inline_completion(
),
)
except Exception as e:
- LOGGER.error("Error in AI inline completion: %s", str(e))
+ LOGGER.error("Error in AI inline completion: %s", e)
raise HTTPException(
status_code=500, # Internal Server Error
detail=f"AI completion failed: {e!s}",
@@ -413,7 +413,7 @@ async def invoke_tool(
)
except Exception as e:
- LOGGER.error("Error invoking AI tool %s: %s", body.tool_name, str(e))
+ LOGGER.error("Error invoking AI tool %s: %s", body.tool_name, e)
# Return error response instead of letting it crash
return StructResponse(
InvokeAiToolResponse(
diff --git a/marimo/_server/api/endpoints/terminal.py b/marimo/_server/api/endpoints/terminal.py
index ca9e0b925f..b450e37031 100644
--- a/marimo/_server/api/endpoints/terminal.py
+++ b/marimo/_server/api/endpoints/terminal.py
@@ -314,7 +314,7 @@ async def _write_to_pty(
while True:
try:
data = await websocket.receive_text()
- LOGGER.debug("Received: %s", repr(data))
+ LOGGER.debug("Received: %r", data)
# Check if this is a resize message
if await _maybe_handle_resize(
diff --git a/marimo/_server/api/endpoints/ws/ws_message_loop.py b/marimo/_server/api/endpoints/ws/ws_message_loop.py
index e03d8b2d7b..c9a75578d9 100644
--- a/marimo/_server/api/endpoints/ws/ws_message_loop.py
+++ b/marimo/_server/api/endpoints/ws/ws_message_loop.py
@@ -77,7 +77,7 @@ def prepare_wire_message(data: KernelMessage, *, is_kiosk: bool) -> str | None:
try:
return format_wire_message(op, data)
except Exception as e:
- LOGGER.error("Failed to deserialize message: %s", str(e))
+ LOGGER.error("Failed to deserialize message: %s", e)
LOGGER.error("Message: %s", data)
return None
diff --git a/marimo/_server/files/directory_scanner.py b/marimo/_server/files/directory_scanner.py
index 4c8a03fe67..7b55ea20f7 100644
--- a/marimo/_server/files/directory_scanner.py
+++ b/marimo/_server/files/directory_scanner.py
@@ -191,7 +191,7 @@ class DirectoryScanner:
try:
entries = os.scandir(directory)
except OSError as e:
- LOGGER.debug("OSError scanning directory: %s", str(e))
+ LOGGER.debug("OSError scanning directory: %s", e)
self.truncated = True
return None
diff --git a/marimo/_session/notebook/file_manager.py b/marimo/_session/notebook/file_manager.py
index 14728b0a11..b3a9a8e4c9 100644
--- a/marimo/_session/notebook/file_manager.py
+++ b/marimo/_session/notebook/file_manager.py
@@ -688,7 +688,7 @@ def read_css_file(css_file: str, filename: str | None) -> str | None:
LOGGER.warning(
"Failed to open custom CSS file %s for reading: %s",
filepath,
- str(e),
+ e,
)
return None
@@ -719,7 +719,7 @@ def read_html_head_file(
LOGGER.warning(
"Failed to open HTML head file %s for reading: %s",
filepath,
- str(e),
+ e,
)
return None
diff --git a/marimo/_session/notebook/storage.py b/marimo/_session/notebook/storage.py
index 8408e765ff..f1e16666fe 100644
--- a/marimo/_session/notebook/storage.py
+++ b/marimo/_session/notebook/storage.py
@@ -214,7 +214,7 @@ class FilesystemStorage(StorageInterface):
LOGGER.warning(
"Failed to open related file %s for reading: %s",
filepath,
- str(e),
+ e,
)
return None
diff --git a/marimo/_utils/distributor.py b/marimo/_utils/distributor.py
index f2ecc5b4b5..1c4d27977d 100644
--- a/marimo/_utils/distributor.py
+++ b/marimo/_utils/distributor.py
@@ -79,9 +79,7 @@ class ConnectionDistributor(Distributor[T_co]):
response = self.input_connection.recv()
except BlockingIOError as e:
# recv() sporadically fails with EAGAIN, EDEADLK ...
- LOGGER.warning(
- "BlockingIOError in distributor receive: %s", str(e)
- )
+ LOGGER.warning("BlockingIOError in distributor receive: %s", e)
time.sleep(retry_sleep_seconds)
continue
except (EOFError, StopIteration):
diff --git a/pyproject.toml b/pyproject.toml
index 0d8d8a09ed..99af42c782 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -382,7 +382,6 @@ ignore = [
# Restored to Ruff's default rule set in 0.16.6; enable incrementally
"RUF069", # Float equality comparison
"PLW0108", # Unnecessary lambda
- "RUF065", # Eager conversion in logging calls
"PLC2801", # Unnecessary dunder call
"FURB189", # Subclassing built-in collections
"FURB152", # Replace literal with a math constant