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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
chore(ruff): enforce exception logging checks (#10722)
Shahmir Varqha90617b1783c0
diff --git a/marimo/_messaging/notification_utils.py b/marimo/_messaging/notification_utils.pyindex f97dbfdd46..267dcdb109 100644--- a/marimo/_messaging/notification_utils.py+++ b/marimo/_messaging/notification_utils.py@@ -53,11 +53,10 @@ def broadcast_notification(try:stream.write(serialize_kernel_message(notification))- except Exception as e:+ except Exception:LOGGER.exception(- "Error serializing notification %s: %s",+ "Error serializing notification %s",notification.__class__.__name__,- e,)returndiff --git a/marimo/_server/api/endpoints/terminal.py b/marimo/_server/api/endpoints/terminal.pyindex 9cd5a13c93..9d7f5245f3 100644--- a/marimo/_server/api/endpoints/terminal.py+++ b/marimo/_server/api/endpoints/terminal.py@@ -430,8 +430,8 @@ async def websocket_endpoint(websocket: WebSocket) -> None:except WebSocketDisconnect:LOGGER.debug("Client disconnected from terminal")- except Exception as e:- LOGGER.exception(f"Terminal websocket error: {e}")+ except Exception:+ LOGGER.exception("Terminal websocket error")finally:# Ensure all tasks are cleaned upawait _cancel_tasks([reader_task, writer_task])diff --git a/marimo/_server/asgi.py b/marimo/_server/asgi.pyindex 3ca5216fee..7710d02487 100644--- a/marimo/_server/asgi.py+++ b/marimo/_server/asgi.py@@ -322,8 +322,8 @@ class DynamicDirectoryMiddleware:notebook_base_url, cache_key)LOGGER.debug(f"Successfully created app for {cache_key}")- except Exception as e:- LOGGER.exception(f"Failed to create app for {cache_key}: {e}")+ except Exception:+ LOGGER.exception("Failed to create app for %s", cache_key)await self.app(scope, receive, send)return@@ -343,9 +343,9 @@ class DynamicDirectoryMiddleware:LOGGER.debug(f"Successfully handled {scope['type']} request for {cache_key}")- except Exception as e:+ except Exception:LOGGER.exception(- f"Error handling {scope['type']} request for {cache_key}: {e}"+ "Error handling %s request for %s", scope["type"], cache_key)# If the app fails, fall back to the main appawait self.app(scope, receive, send)diff --git a/marimo/_tracer.py b/marimo/_tracer.pyindex 941a460817..a1087e852f 100644--- a/marimo/_tracer.py+++ b/marimo/_tracer.py@@ -218,8 +218,8 @@ def _set_tracer_provider() -> None:f.write(span.to_json(cast(Any, None)))f.write("\n")return SpanExportResult.SUCCESS- except Exception as e:- LOGGER.exception(e)+ except Exception:+ LOGGER.exception("Failed to write trace spans")return SpanExportResult.FAILUREdef shutdown(self) -> None:diff --git a/pyproject.toml b/pyproject.tomlindex fa3f1a45f4..0fdde423d2 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -373,7 +373,6 @@ ignore = ["DTZ006", # `datetime.fromtimestamp()` called without `tzinfo`"DTZ007", # `datetime.strptime()` called without zone"DTZ011", # `date.today()` used- "TRY401", # Verbose log message"UP007", # Use `X | Y` for type annotations"DTZ012", # `date.fromtimestamp()` called without `tzinfo`"DTZ901", # `datetime.min` / `datetime.max` used@@ -382,6 +381,29 @@ ignore = ["DTZ002", # `datetime.today()` called without tz"PLE0704", # Misplaced bare `raise`"D421", # Property docstring should not start with a verb (preview rule)++ # Restored to Ruff's default rule set in 0.16.6; enable incrementally+ "RUF069", # Float equality comparison+ "PLW0108", # Unnecessary lambda+ "RUF043", # Ambiguous pattern in `pytest.raises`+ "RUF065", # Eager conversion in logging calls+ "PLC2801", # Unnecessary dunder call+ "FURB189", # Subclassing built-in collections+ "FURB152", # Replace literal with a math constant+ "FURB110", # Replace ternary with an `or` expression+ "RUF036", # `None` is not last in a union+ "FURB113", # Repeated `append` calls+ "C420", # Unnecessary dictionary comprehension+ "PLC0207", # Missing `maxsplit` argument+ "RUF075", # Fallible context manager+ "FURB171", # Single-item membership test+ "FURB142", # Set mutation in a loop+ "NPY002", # Legacy NumPy random API+ "RUF027", # Possible missing f-string prefix+ "SIM110", # Reimplemented built-in+ "FURB145", # Slice used to copy a collection+ "RUF055", # Unnecessary regular expression+ "RUF100", # Unused `noqa` directive]extend-select = [