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: silence some type errors (#1079)
Akshay Agrawal8aabbcb0a58d
diff --git a/marimo/_output/formatters/matplotlib_formatters.py b/marimo/_output/formatters/matplotlib_formatters.pyindex ddf7b101c8..536328804b 100644--- a/marimo/_output/formatters/matplotlib_formatters.py+++ b/marimo/_output/formatters/matplotlib_formatters.py@@ -31,7 +31,7 @@ class MatplotlibFormatter(FormatterFactory):def mime_data_artist(artist: Artist) -> tuple[KnownMimeType, str]:buf = io.BytesIO()- artist.figure.savefig(buf, format="png")+ artist.figure.savefig(buf, format="png") # type: ignoremimetype: KnownMimeType = "image/png"plot_bytes = base64.b64encode(buf.getvalue())return (@@ -41,13 +41,13 @@ class MatplotlibFormatter(FormatterFactory):# monkey-patch a _mime_ method, instead of using a formatter, because# we want all subclasses of Artist to inherit this renderer.- Artist._mime_ = mime_data_artist+ Artist._mime_ = mime_data_artist # type: ignore[attr-defined]# use an explicit formatter, no need to try to format subclasses of# BarContainer@formatting.formatter(BarContainer)def _show_bar_container(bc: BarContainer) -> tuple[KnownMimeType, str]:if len(bc.patches) > 0:- return mime_data_artist(bc.patches[0].figure)+ return mime_data_artist(bc.patches[0].figure) # type: ignoreelse:return ("text/plain", str(bc))diff --git a/marimo/_output/mpl.py b/marimo/_output/mpl.pyindex e2e6da5fe5..65f2bcdace 100644--- a/marimo/_output/mpl.py+++ b/marimo/_output/mpl.py@@ -16,7 +16,11 @@ import iofrom typing import Optionalimport matplotlib.pyplot as plt # type: ignore-from matplotlib.backend_bases import FigureManagerBase, Gcf # type: ignore+from matplotlib.backend_bases import ( # type: ignore+ FigureCanvasBase,+ FigureManagerBase,+ Gcf,+)from matplotlib.backends.backend_agg import FigureCanvasAgg # type: ignorefrom marimo._messaging.cell_output import CellChannel@@ -32,7 +36,7 @@ def close_figures() -> None:plt.close("all")-def _internal_show(canvas: FigureCanvasAgg) -> None:+def _internal_show(canvas: FigureCanvasBase) -> None:buf = io.BytesIO()buf.seek(0)canvas.figure.savefig(buf, format="png")diff --git a/marimo/_plugins/stateless/mpl/_mpl.py b/marimo/_plugins/stateless/mpl/_mpl.pyindex 46f598b5a3..bb7c27debf 100644--- a/marimo/_plugins/stateless/mpl/_mpl.py+++ b/marimo/_plugins/stateless/mpl/_mpl.py@@ -68,8 +68,8 @@ def create_application(host: str,port: int,) -> Starlette:- import matplotlib as mpl # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501- from matplotlib.backends.backend_webagg import ( # type: ignore[import-not-found] # noqa: E501+ import matplotlib as mpl # type: ignore+ from matplotlib.backends.backend_webagg import ( # type: ignoreFigureManagerWebAgg,)from starlette.applications import Starlette@@ -88,7 +88,7 @@ def create_application(async def mpl_js(request: Request) -> Response:del requestreturn Response(- content=FigureManagerWebAgg.get_javascript(),+ content=FigureManagerWebAgg.get_javascript(), # type: ignoremedia_type="application/javascript",)@@ -167,7 +167,7 @@ def create_application(Mount("/mpl/_static",StaticFiles(- directory=FigureManagerWebAgg.get_static_file_path()+ directory=FigureManagerWebAgg.get_static_file_path() # type: ignore # noqa: E501),name="mpl_static",),@@ -246,7 +246,7 @@ def interactive(figure: "Figure | Axes") -> Html: # type: ignore[name-defined]from matplotlib.axes import ( # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501Axes,)- from matplotlib.backends.backend_webagg import (+ from matplotlib.backends.backend_webagg import ( # type: ignorenew_figure_manager_given_figure,)diff --git a/marimo/_utils/file_watcher.py b/marimo/_utils/file_watcher.pyindex 8cf44b615c..a4e2e9f8ca 100644--- a/marimo/_utils/file_watcher.py+++ b/marimo/_utils/file_watcher.py@@ -103,19 +103,19 @@ def _create_watchdog(self.loop.create_task(self.on_file_changed())def start(self) -> None:- event_handler = watchdog.events.PatternMatchingEventHandler(+ event_handler = watchdog.events.PatternMatchingEventHandler( # type: ignore # noqa: E501patterns=[str(self.path)])- event_handler.on_modified = self.on_modified- self.observer.schedule(+ event_handler.on_modified = self.on_modified # type: ignore+ self.observer.schedule( # type: ignoreevent_handler,str(self.path.parent),recursive=False,)- self.observer.start()+ self.observer.start() # type: ignoredef stop(self) -> None:- self.observer.stop()+ self.observer.stop() # type: ignoreself.observer.join()return WatchdogFileWatcher(path, callback, loop)