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: upgrade ruff, fix lint errors (#1721)
Myles Scolnickda866949b6d5
diff --git a/marimo/_server/api/endpoints/assets.py b/marimo/_server/api/endpoints/assets.pyindex b3f6c145bb..65296f4d34 100644--- a/marimo/_server/api/endpoints/assets.py+++ b/marimo/_server/api/endpoints/assets.py@@ -59,7 +59,7 @@ async def index(request: Request) -> HTMLResponse:or app_state.session_manager.file_router.get_unique_file_key())- with open(index_html, "r") as f: # noqa: ASYNC101+ with open(index_html, "r") as f: # noqa: ASYNC101 ASYNC230html = f.read()if not file_key:diff --git a/marimo/_server/export/exporter.py b/marimo/_server/export/exporter.pyindex 45a6410d94..840de66336 100644--- a/marimo/_server/export/exporter.py+++ b/marimo/_server/export/exporter.py@@ -49,7 +49,7 @@ class Exporter:cell_ids = list(file_manager.app.cell_manager.cell_ids())filename = get_filename(file_manager)- with open(index_html_file, "r") as f: # noqa: ASYNC101+ with open(index_html_file, "r") as f: # noqa: ASYNC101 ASYNC230index_html = f.read()files: dict[str, str] = {}diff --git a/marimo/_utils/parse_dataclass.py b/marimo/_utils/parse_dataclass.pyindex e219868b9d..2eaa80ac92 100644--- a/marimo/_utils/parse_dataclass.py+++ b/marimo/_utils/parse_dataclass.py@@ -40,7 +40,7 @@ def _build_value(value: Any, cls: Type[T]) -> T:elif origin_cls in (list, set):(arg_type,) = get_args(cls)return origin_cls(_build_value(v, arg_type) for v in value) # type: ignore # noqa: E501- elif origin_cls == tuple:+ elif origin_cls is tuple:arg_types = get_args(cls)if len(arg_types) == 2 and isinstance(arg_types[1], type(Ellipsis)):return origin_cls(_build_value(v, arg_types[0]) for v in value) # type: ignore # noqa: E501@@ -48,7 +48,7 @@ def _build_value(value: Any, cls: Type[T]) -> T:return origin_cls( # type: ignore # noqa: E501_build_value(v, t) for v, t in zip(value, arg_types))- elif origin_cls == dict:+ elif origin_cls is dict:key_type, value_type = get_args(cls)return origin_cls( # type: ignore[no-any-return]**{diff --git a/pyproject.toml b/pyproject.tomlindex e557e11abf..cf6532f179 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -95,7 +95,7 @@ dev = ["types-Markdown~=3.6.0.20240316","types-PyYAML~=6.0.12.20240311","mypy~=1.10.0",- "ruff~=0.3.6",+ "ruff~=0.5.0","typos~=1.17.1",# For docs"pypandoc~=1.11",diff --git a/tests/_cli/test_cli_export.py b/tests/_cli/test_cli_export.pyindex e79ab26ed8..a7a0db3aff 100644--- a/tests/_cli/test_cli_export.py+++ b/tests/_cli/test_cli_export.py@@ -74,7 +74,7 @@ class TestExportHTML:)async def test_export_watch(self, temp_marimo_file: str) -> None:temp_out_file = temp_marimo_file.replace(".py", ".html")- p = subprocess.Popen( # noqa: ASYNC101+ p = subprocess.Popen( # noqa: ASYNC101 ASYNC220["marimo","export",@@ -98,7 +98,7 @@ class TestExportHTML:assert not path.exists(temp_out_file)# Modify file- with open(temp_marimo_file, "a") as f: # noqa: ASYNC101+ with open(temp_marimo_file, "a") as f: # noqa: ASYNC101 ASYNC230f.write("\n# comment\n")assert p.poll() is None@@ -258,7 +258,7 @@ class TestExportScript:)async def test_export_watch_script(self, temp_marimo_file: str) -> None:temp_out_file = temp_marimo_file.replace(".py", ".script.py")- p = subprocess.Popen( # noqa: ASYNC101+ p = subprocess.Popen( # noqa: ASYNC101 ASYNC220["marimo","export",@@ -282,7 +282,7 @@ class TestExportScript:assert not path.exists(temp_out_file)# Modify file- with open(temp_marimo_file, "a") as f: # noqa: ASYNC101+ with open(temp_marimo_file, "a") as f: # noqa: ASYNC101 ASYNC230f.write("\n# comment\n")assert p.poll() is None@@ -367,7 +367,7 @@ class TestExportMarkdown:)async def test_export_watch_script(self, temp_marimo_file: str) -> None:temp_out_file = temp_marimo_file.replace(".md", ".script.md")- p = subprocess.Popen( # noqa: ASYNC101+ p = subprocess.Popen( # noqa: ASYNC101 ASYNC220["marimo","export",@@ -391,7 +391,7 @@ class TestExportMarkdown:assert not path.exists(temp_out_file)# Modify file- with open(temp_marimo_file, "a") as f: # noqa: ASYNC101+ with open(temp_marimo_file, "a") as f: # noqa: ASYNC101 ASYNC230f.write("\n# comment\n")assert p.poll() is Nonediff --git a/tests/_plugins/stateless/test_image.py b/tests/_plugins/stateless/test_image.pyindex 5aa56919a1..fb70c32af2 100644--- a/tests/_plugins/stateless/test_image.py+++ b/tests/_plugins/stateless/test_image.py@@ -1,4 +1,6 @@# Copyright 2024 Marimo. All rights reserved.+from __future__ import annotations+import sysimport pytest@@ -111,7 +113,7 @@ async def test_image_numpy(k: Kernel, exec_req: ExecReqProvider) -> None:async def test_image_local_file(k: Kernel, exec_req: ExecReqProvider) -> None:# Just opens a file that exists, and make sure it gets registered# in the virtual path registry- with open(__file__, encoding="utf-8") as f: # noqa: ASYNC101+ with open(__file__, encoding="utf-8") as f: # noqa: ASYNC101 ASYNC230await k.run([exec_req.get(diff --git a/tests/_smoke_tests/run_all.py b/tests/_smoke_tests/run_all.pyindex b19b10a8c8..fa9e908179 100644--- a/tests/_smoke_tests/run_all.py+++ b/tests/_smoke_tests/run_all.py@@ -23,7 +23,7 @@ async def test_all_smoke_tests() -> None:all_py_paths = list(pathlib.Path(root).rglob("*.py"))assert all_py_paths, "No smoke tests found"- with open(config_file, "r") as f: # noqa: ASYNC101+ with open(config_file, "r") as f: # noqa: ASYNC101 ASYNC230smoke_test_config = yaml.load(f.read(), Loader=yaml.FullLoader)semaphore = asyncio.Semaphore(CONCURRENT_TESTS)@@ -41,7 +41,7 @@ async def test_all_examples() -> None:all_py_paths = list(pathlib.Path(root).rglob("*.py"))assert all_py_paths, "No examples found"- with open(config_file, "r") as f: # noqa: ASYNC101+ with open(config_file, "r") as f: # noqa: ASYNC101 ASYNC230smoke_test_config = yaml.load(f.read(), Loader=yaml.FullLoader)semaphore = asyncio.Semaphore(CONCURRENT_TESTS)@@ -68,7 +68,7 @@ async def _run_test(failed_reason = file_config.get("failed_reason", None)input_data = file_config.get("input", None)- with open(file, "r") as f: # noqa: ASYNC101+ with open(file, "r") as f: # noqa: ASYNC101 ASYNC230content = f.read()if "marimo.App(" not in content:returndiff --git a/tests/_utils/test_file_watcher.py b/tests/_utils/test_file_watcher.pyindex ad891a87e1..84c0dd343d 100644--- a/tests/_utils/test_file_watcher.py+++ b/tests/_utils/test_file_watcher.py@@ -28,7 +28,7 @@ async def test_polling_file_watcher() -> None:# Wait a bit and then modify the fileawait asyncio.sleep(0.2)- with open(tmp_path, "w") as f: # noqa: ASYNC101+ with open(tmp_path, "w") as f: # noqa: ASYNC101 ASYNC230f.write("modification")# Wait for the watcher to detect the change