From e5e464abf7eff190b36ca63e29abb2c6bd931cca Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 16:06:09 -0700 Subject: [PATCH 1/9] remove 3.8 support, test 3.13 --- .github/workflows/test_be.yaml | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_be.yaml b/.github/workflows/test_be.yaml index 6373cb0ba07..0fd54dcc418 100644 --- a/.github/workflows/test_be.yaml +++ b/.github/workflows/test_be.yaml @@ -38,11 +38,8 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] dependencies: ['core', 'core,optional'] - python-version: ['3.8'] + python-version: ['3.9'] include: - - os: ubuntu-latest - python-version: '3.9' - dependencies: 'core' - os: ubuntu-latest python-version: '3.10' dependencies: 'core' @@ -64,6 +61,9 @@ jobs: - os: ubuntu-latest python-version: '3.12' dependencies: 'core,optional' + - os: ubuntu-latest + python-version: '3.13' + dependencies: 'core,optional' steps: - name: 🛑 Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 diff --git a/pyproject.toml b/pyproject.toml index 9665dbab02e..9001c8f934c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ ] readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.8" +requires-python = ">=3.9" classifiers = [ "Operating System :: OS Independent", "License :: OSI Approved :: Apache Software License", From 4b7cf7e9047b95a79cfd62b39c46a1ab31de7788 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 16:09:10 -0700 Subject: [PATCH 2/9] Revert "remove 3.8 support, test 3.13" This reverts commit e5e464abf7eff190b36ca63e29abb2c6bd931cca. --- .github/workflows/test_be.yaml | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_be.yaml b/.github/workflows/test_be.yaml index 0fd54dcc418..6373cb0ba07 100644 --- a/.github/workflows/test_be.yaml +++ b/.github/workflows/test_be.yaml @@ -38,8 +38,11 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] dependencies: ['core', 'core,optional'] - python-version: ['3.9'] + python-version: ['3.8'] include: + - os: ubuntu-latest + python-version: '3.9' + dependencies: 'core' - os: ubuntu-latest python-version: '3.10' dependencies: 'core' @@ -61,9 +64,6 @@ jobs: - os: ubuntu-latest python-version: '3.12' dependencies: 'core,optional' - - os: ubuntu-latest - python-version: '3.13' - dependencies: 'core,optional' steps: - name: 🛑 Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 diff --git a/pyproject.toml b/pyproject.toml index 9001c8f934c..9665dbab02e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ ] readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.9" +requires-python = ">=3.8" classifiers = [ "Operating System :: OS Independent", "License :: OSI Approved :: Apache Software License", From 282d9d431bebb1c28f63a8e7ad0a0cc641312557 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 16:10:27 -0700 Subject: [PATCH 3/9] drop 3.8 support --- marimo/_utils/paths.py | 6 +----- pyproject.toml | 6 ++---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/marimo/_utils/paths.py b/marimo/_utils/paths.py index 5828adff5a5..b2c6eb6917b 100644 --- a/marimo/_utils/paths.py +++ b/marimo/_utils/paths.py @@ -2,15 +2,11 @@ from __future__ import annotations import os -import sys from typing import Any def import_files(filename: str) -> Any: - if sys.version_info < (3, 9): - from importlib_resources import files as importlib_files - else: - from importlib.resources import files as importlib_files + from importlib.resources import files as importlib_files return importlib_files(filename) diff --git a/pyproject.toml b/pyproject.toml index 9665dbab02e..d084c4961c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,8 +12,6 @@ dynamic = ["version"] dependencies = [ # For maintainable cli "click>=8.0,<9", - # For python 3.8 compatibility - "importlib_resources>=5.10.2; python_version < \"3.9\"", # code completion "jedi>=0.18.0", # compile markdown to html @@ -51,7 +49,7 @@ dependencies = [ ] readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.8" +requires-python = ">=3.9" classifiers = [ "Operating System :: OS Independent", "License :: OSI Approved :: Apache Software License", @@ -61,10 +59,10 @@ classifiers = [ "Intended Audience :: Science/Research", "Intended Audience :: Education", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3 :: Only", ] From 83caeeaec4181bc7d77a33a4dc9cd58340bb5b7c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:10:55 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- marimo/_runtime/runtime.py | 22 +++++++++++++--------- tests/_cli/test_file_path.py | 25 ++++++++++++------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.py index 8ac3299c9a6..7cf7f45344b 100644 --- a/marimo/_runtime/runtime.py +++ b/marimo/_runtime/runtime.py @@ -522,12 +522,15 @@ def _install_execution_context( self.execution_context = ExecutionContext( cell_id, setting_element_value ) - with get_context().provide_ui_ids(str(cell_id)), redirect_streams( - cell_id, - stream=self.stream, - stdout=self.stdout, - stderr=self.stderr, - stdin=self.stdin, + with ( + get_context().provide_ui_ids(str(cell_id)), + redirect_streams( + cell_id, + stream=self.stream, + stdout=self.stdout, + stderr=self.stderr, + stdin=self.stdin, + ), ): modules = None try: @@ -1590,9 +1593,10 @@ def debug(title: str, message: str) -> None: else: found = True LOGGER.debug("Executing RPC %s", request) - with self._install_execution_context( - cell_id=function.cell_id - ), ctx.provide_ui_ids(str(uuid4())): + with ( + self._install_execution_context(cell_id=function.cell_id), + ctx.provide_ui_ids(str(uuid4())), + ): # Usually UI element IDs are deterministic, based on # cell id, so that element values can be matched up # with objects on notebook/app re-connection. diff --git a/tests/_cli/test_file_path.py b/tests/_cli/test_file_path.py index 05fde4e7136..ef75e27157b 100644 --- a/tests/_cli/test_file_path.py +++ b/tests/_cli/test_file_path.py @@ -165,17 +165,15 @@ def test_generic_url_reader() -> None: def test_file_content_reader() -> None: reader = FileContentReader() - with patch.object( - LocalFileReader, "read" - ) as mock_local_read, patch.object( - GitHubIssueReader, "read" - ) as mock_github_issue_read, patch.object( - StaticNotebookReader, "read" - ) as mock_static_notebook_read, patch.object( - GitHubSourceReader, "read" - ) as mock_github_source_read, patch.object( - GenericURLReader, "read" - ) as mock_generic_url_read: + with ( + patch.object(LocalFileReader, "read") as mock_local_read, + patch.object(GitHubIssueReader, "read") as mock_github_issue_read, + patch.object( + StaticNotebookReader, "read" + ) as mock_static_notebook_read, + patch.object(GitHubSourceReader, "read") as mock_github_source_read, + patch.object(GenericURLReader, "read") as mock_generic_url_read, + ): mock_local_read.return_value = ("local content", "local.py") mock_github_issue_read.return_value = ("issue content", "issue.py") mock_static_notebook_read.return_value = ( @@ -337,8 +335,9 @@ def test_validate_name_with_relative_and_absolute_paths(): relative_path = "relative/path/file.py" absolute_path = "/absolute/path/file.py" - with patch("os.path.exists", return_value=True), patch( - "pathlib.Path.is_file", return_value=True + with ( + patch("os.path.exists", return_value=True), + patch("pathlib.Path.is_file", return_value=True), ): assert ( validate_name( From 518d2d38c5c6d760c985389c4c0efd99f5e4b210 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 16:24:49 -0700 Subject: [PATCH 5/9] remove 38 from test_be --- .github/workflows/test_be.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test_be.yaml b/.github/workflows/test_be.yaml index 6373cb0ba07..7cef04e55c6 100644 --- a/.github/workflows/test_be.yaml +++ b/.github/workflows/test_be.yaml @@ -38,11 +38,8 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] dependencies: ['core', 'core,optional'] - python-version: ['3.8'] + python-version: ['3.9'] include: - - os: ubuntu-latest - python-version: '3.9' - dependencies: 'core' - os: ubuntu-latest python-version: '3.10' dependencies: 'core' From 97d600d41d527a68ca1f3e1cb037cacf6442e854 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 16:27:32 -0700 Subject: [PATCH 6/9] remove 3.8 version checks --- marimo/_convert/ipynb.py | 11 ----------- marimo/_plugins/ui/_impl/batch.py | 7 ------- marimo/_runtime/copy.py | 7 +------ marimo/_runtime/primitives.py | 7 +------ marimo/_server/api/lifespans.py | 17 ++++------------- 5 files changed, 6 insertions(+), 43 deletions(-) diff --git a/marimo/_convert/ipynb.py b/marimo/_convert/ipynb.py index 48da78fc02e..8c329b2ace3 100644 --- a/marimo/_convert/ipynb.py +++ b/marimo/_convert/ipynb.py @@ -26,10 +26,6 @@ def transform_fixup_multiple_definitions(sources: List[str]) -> List[str]: This only takes effect if the declaration and reference are in the same cell. """ - if sys.version_info < (3, 9): - # ast.unparse not available in Python 3.8 - return sources - try: cells = [ compile_cell(source, cell_id=str(i)) @@ -355,10 +351,6 @@ def rename_named_node( def _transform_aug_assign(sources: List[str]) -> List[str]: - if sys.version_info < (3, 9): - # ast.unparse unavailable - return sources - new_sources = sources.copy() for i, source in enumerate(sources): try: @@ -433,9 +425,6 @@ def transform_duplicate_definitions(sources: List[str]) -> List[str]: print(a_2) ``` """ - if sys.version_info < (3, 9): - # ast.unparse not available in Python 3.8 - return sources # Find all definitions in the AST def find_definitions(node: ast.AST) -> List[str]: diff --git a/marimo/_plugins/ui/_impl/batch.py b/marimo/_plugins/ui/_impl/batch.py index 321bff3ccf9..416314c3801 100644 --- a/marimo/_plugins/ui/_impl/batch.py +++ b/marimo/_plugins/ui/_impl/batch.py @@ -1,13 +1,6 @@ # Copyright 2024 Marimo. All rights reserved. from __future__ import annotations -import sys - -if sys.version_info < (3, 9): - from typing import ItemsView, ValuesView -else: - pass - from typing import ( TYPE_CHECKING, Any, diff --git a/marimo/_runtime/copy.py b/marimo/_runtime/copy.py index f920b90138f..cb7eaaacf25 100644 --- a/marimo/_runtime/copy.py +++ b/marimo/_runtime/copy.py @@ -2,7 +2,6 @@ from __future__ import annotations import inspect -import sys import weakref from copy import copy from typing import ( @@ -16,11 +15,7 @@ ) T = TypeVar("T") -if sys.version_info < (3, 9): - # Future does not seem to work for this in CI. - Ref = Union["weakref.ReferenceType[T]", Callable[[], T]] -else: - Ref = Union[weakref.ReferenceType[T], Callable[[], T]] +Ref = Union[weakref.ReferenceType[T], Callable[[], T]] class CloneError(Exception): diff --git a/marimo/_runtime/primitives.py b/marimo/_runtime/primitives.py index 7c863944ed9..cc5acee99ad 100644 --- a/marimo/_runtime/primitives.py +++ b/marimo/_runtime/primitives.py @@ -3,7 +3,6 @@ import inspect import numbers -import sys import weakref from typing import TYPE_CHECKING, Any, Callable, Optional, Union @@ -18,11 +17,7 @@ # reference. CLONE_PRIMITIVES = (weakref.ref,) + PRIMITIVES -if sys.version_info < (3, 9): - # Future does not seem to work for this in CI. - FN_CACHE_TYPE = Optional["dict[Union[Callable[..., Any], type], bool]"] -else: - FN_CACHE_TYPE = Optional[dict[Union[Callable[..., Any], type], bool]] +FN_CACHE_TYPE = Optional[dict[Union[Callable[..., Any], type], bool]] def is_external(value: Any) -> bool: diff --git a/marimo/_server/api/lifespans.py b/marimo/_server/api/lifespans.py index b9f36b31b70..23abadce187 100644 --- a/marimo/_server/api/lifespans.py +++ b/marimo/_server/api/lifespans.py @@ -5,25 +5,16 @@ import contextlib import socket import sys +from collections.abc import AsyncIterator, Callable, Sequence +from contextlib import AbstractAsyncContextManager + +from starlette.applications import Starlette from marimo._server.api.deps import AppState, AppStateBase from marimo._server.file_router import AppFileRouter from marimo._server.sessions import SessionManager from marimo._server.tokens import AuthToken -if sys.version_info < (3, 9): - from typing import ( - AsyncContextManager as AbstractAsyncContextManager, - AsyncIterator, - Callable, - Sequence, - ) -else: - from collections.abc import AsyncIterator, Callable, Sequence - from contextlib import AbstractAsyncContextManager - -from starlette.applications import Starlette - if sys.version_info < (3, 10): from typing_extensions import TypeAlias else: From 6f6d0d4fa071e2c309c42311a8fc655fee1f1d5e Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 16:41:52 -0700 Subject: [PATCH 7/9] windows compat --- tests/_runtime/test_trace.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/_runtime/test_trace.py b/tests/_runtime/test_trace.py index 3db45176b80..f036da7c6ca 100644 --- a/tests/_runtime/test_trace.py +++ b/tests/_runtime/test_trace.py @@ -22,10 +22,7 @@ def test_script_trace() -> None: result = p.stderr.decode() assert "NameError: name 'y' is not defined" in result - assert ( - 'tests/_runtime/script_data/script_exception.py", line 10' - in result - ) + assert 'script_exception.py", line 10' in result assert "y = y / x" in result # Test col_offset # Expected output: @@ -50,10 +47,7 @@ def test_script_trace_with_output() -> None: result = p.stderr.decode() assert "ZeroDivisionError: division by zero" in result - assert ( - 'tests/_runtime/script_data/script_exception_with_output.py"' - ", line 11" - ) in result + assert ('script_exception_with_output.py"' ", line 11") in result assert "y / x" in result @staticmethod From c7f01553107c9b5a0db47a337e1bbc5cce8e26b9 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 17:22:16 -0700 Subject: [PATCH 8/9] more windows compat --- tests/_runtime/test_trace.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/_runtime/test_trace.py b/tests/_runtime/test_trace.py index f036da7c6ca..f1f0c3ff38f 100644 --- a/tests/_runtime/test_trace.py +++ b/tests/_runtime/test_trace.py @@ -69,7 +69,9 @@ def test_script_trace_with_imported_file() -> None: assert f'{file_path}", line 3' in result assert ( - 'tests/_runtime/script_data/script_exception_with_imported_function.py"' + os.path.normpath( + "tests/_runtime/script_data/script_exception_with_imported_function.py" # noqa: E501 + ) + ", line 11" in result ) From 8c5a7f23470c2d26074994451af799d16751ef80 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 1 Oct 2024 17:39:17 -0700 Subject: [PATCH 9/9] fix test --- tests/_runtime/test_trace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/_runtime/test_trace.py b/tests/_runtime/test_trace.py index f1f0c3ff38f..f8e8d11657e 100644 --- a/tests/_runtime/test_trace.py +++ b/tests/_runtime/test_trace.py @@ -72,7 +72,7 @@ def test_script_trace_with_imported_file() -> None: os.path.normpath( "tests/_runtime/script_data/script_exception_with_imported_function.py" # noqa: E501 ) - + ", line 11" + + '", line 11' in result ) assert "y = y / x" in result