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): enable bad exit annotations (#10791)
Shahmir Varqha112a7011bc31
diff --git a/marimo/_plugins/stateless/status/_progress.py b/marimo/_plugins/stateless/status/_progress.pyindex 6311acb5a1..f8d03f5931 100644--- a/marimo/_plugins/stateless/status/_progress.py+++ b/marimo/_plugins/stateless/status/_progress.py@@ -6,7 +6,6 @@ import timefrom collections.abc import AsyncIterable, Iterable, Sizedfrom typing import (TYPE_CHECKING,- Any,Generic,Literal,TypeVar,@@ -25,6 +24,7 @@ from marimo._utils.debounce import debounceif TYPE_CHECKING:from collections.abc import AsyncIterator, Collection, Iterator+ from types import TracebackTypeS = TypeVar("S")T = TypeVar("T")@@ -272,7 +272,12 @@ class spinner:output.append(self.spinner)return self.spinner- def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:+ def __exit__(+ self,+ exc_type: type[BaseException] | None,+ exc_value: BaseException | None,+ traceback: TracebackType | None,+ ) -> None:if self.remove_on_exit:self.spinner.clear()# TODO(akshayka): else consider transitioning to a done state@@ -465,7 +470,12 @@ class progress_bar(Generic[S]):def __enter__(self) -> ProgressBar:return self.progress- def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:+ def __exit__(+ self,+ exc_type: type[BaseException] | None,+ exc_value: BaseException | None,+ traceback: TracebackType | None,+ ) -> None:self._finish()def _finish(self) -> None:diff --git a/marimo/_runtime/_wasm/_concurrency/_mp_pool.py b/marimo/_runtime/_wasm/_concurrency/_mp_pool.pyindex 3ef4749d09..22f349e446 100644--- a/marimo/_runtime/_wasm/_concurrency/_mp_pool.py+++ b/marimo/_runtime/_wasm/_concurrency/_mp_pool.py@@ -349,7 +349,7 @@ class AsyncPool:self._check_running()return self- def __exit__(self, *exc: Any) -> None:+ def __exit__(self, *exc: object) -> None:del excself.terminate()diff --git a/marimo/_runtime/runner/scheduler.py b/marimo/_runtime/runner/scheduler.pyindex d882c369b4..6d5ea73c4f 100644--- a/marimo/_runtime/runner/scheduler.py+++ b/marimo/_runtime/runner/scheduler.py@@ -70,7 +70,7 @@ class Scheduler(Protocol):def cancel_all(self) -> None: ...async def __aenter__(self) -> Self: ...- async def __aexit__(self, *exc_info: Any) -> None: ...+ async def __aexit__(self, *exc_info: object) -> None: ...class SequentialScheduler:@@ -238,7 +238,7 @@ class SequentialScheduler:ctx._active_scheduler = selfreturn self- async def __aexit__(self, *exc_info: Any) -> None:+ async def __aexit__(self, *exc_info: object) -> None:from marimo._runtime.context.kernel_context import (KernelRuntimeContext,)diff --git a/marimo/_utils/background_task.py b/marimo/_utils/background_task.pyindex 4bf0beb619..a29883ca15 100644--- a/marimo/_utils/background_task.py+++ b/marimo/_utils/background_task.py@@ -4,11 +4,13 @@ from __future__ import annotationsimport asyncioimport concurrent.futuresfrom abc import ABC, abstractmethod-from typing import TYPE_CHECKING, Any, final+from typing import TYPE_CHECKING, finalfrom marimo import _loggersif TYPE_CHECKING:+ from types import TracebackType+from typing_extensions import SelfLOGGER = _loggers.marimo_logger()@@ -146,7 +148,10 @@ class AsyncBackgroundTask(ABC):return selfasync def __aexit__(- self, exc_type: Any, exc_val: Any, exc_tb: Any+ self,+ exc_type: type[BaseException] | None,+ exc_val: BaseException | None,+ exc_tb: TracebackType | None,) -> None:"""Async context manager exit.diff --git a/pyproject.toml b/pyproject.tomlindex c55fa441c7..e93db039d2 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -367,7 +367,6 @@ ignore = ["SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements"RUF012", # Mutable class default"S102", # Use of `exec`- "PYI036", # Bad `sys.exit` annotation"DTZ005", # `datetime.now()` called without `tzinfo`"SIM115", # Open file without context handler"DTZ006", # `datetime.fromtimestamp()` called without `tzinfo`diff --git a/tests/_export/test_pdf_raster.py b/tests/_export/test_pdf_raster.pyindex 3928298889..d1625278e5 100644--- a/tests/_export/test_pdf_raster.py+++ b/tests/_export/test_pdf_raster.py@@ -499,7 +499,7 @@ def test_capture_pngs_from_page_reports_progress_in_notebook_order() -> None:async def __aenter__(self) -> _FakePlaywright:return self._playwright- async def __aexit__(self, *args: Any) -> bool:+ async def __aexit__(self, *args: object) -> bool:del argsreturn Falsediff --git a/tests/_server/api/endpoints/test_sse.py b/tests/_server/api/endpoints/test_sse.pyindex 4d94d9e410..1c9542c693 100644--- a/tests/_server/api/endpoints/test_sse.py+++ b/tests/_server/api/endpoints/test_sse.py@@ -87,7 +87,7 @@ class SSETestConnection:)return self- async def __aexit__(self, *args: Any) -> None:+ async def __aexit__(self, *args: object) -> None:self.disconnect()assert self._task is not Noneawait asyncio.wait_for(self._task, timeout=10)diff --git a/tests/conftest.py b/tests/conftest.pyindex b5fb281134..31eee79422 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -38,7 +38,7 @@ _MockStream = MockStreamif TYPE_CHECKING:from collections.abc import Generator- from types import ModuleType+ from types import ModuleType, TracebackTypefrom typing_extensions import Self@@ -490,9 +490,14 @@ class MockPyodide:self._stack = stackreturn self- def __exit__(self, *exc: Any) -> None:+ def __exit__(+ self,+ exc_type: type[BaseException] | None,+ exc_value: BaseException | None,+ traceback: TracebackType | None,+ ) -> None:assert self._stack is not None- self._stack.__exit__(*exc)+ self._stack.__exit__(exc_type, exc_value, traceback)self._stack = Nonedef __call__(self, func: Any) -> Any: