Skip to content

Commit f7e1c4e

Browse files
committed
tidy: remove python 3.9 support
1 parent 7fa7821 commit f7e1c4e

File tree

20 files changed

+101
-184
lines changed

20 files changed

+101
-184
lines changed

marimo/_ast/app.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import os
77
import sys
88
import threading
9-
from collections.abc import Iterable, Iterator, Mapping
9+
from collections.abc import (
10+
Iterable,
11+
Iterator,
12+
Mapping,
13+
Sequence, # noqa: TC003
14+
)
1015
from dataclasses import dataclass
1116
from pathlib import Path
1217
from textwrap import dedent
@@ -16,40 +21,28 @@
1621
Callable,
1722
Literal,
1823
Optional,
24+
ParamSpec,
25+
TypeAlias,
1926
TypeVar,
2027
Union,
2128
cast,
2229
overload,
2330
)
2431

25-
from marimo._ast.app_config import _AppConfig
26-
from marimo._ast.cell_id import external_prefix
27-
from marimo._ast.parse import ast_parse
28-
from marimo._ast.variables import BUILTINS
29-
from marimo._convert.converters import MarimoConvert
30-
from marimo._schemas.serialization import (
31-
AppInstantiation,
32-
CellDef,
33-
NotebookSerializationV1,
34-
)
35-
from marimo._types.ids import CellId_t
36-
37-
if sys.version_info < (3, 10):
38-
from typing_extensions import ParamSpec, TypeAlias
39-
else:
40-
from typing import ParamSpec, TypeAlias
41-
42-
from collections.abc import Sequence # noqa: TC003
43-
4432
from marimo import _loggers
33+
from marimo._ast.app_config import _AppConfig
4534
from marimo._ast.cell import Cell, CellConfig, CellImpl
35+
from marimo._ast.cell_id import external_prefix
4636
from marimo._ast.cell_manager import CellManager
4737
from marimo._ast.errors import (
4838
CycleError,
4939
MultipleDefinitionError,
5040
SetupRootError,
5141
UnparsableError,
5242
)
43+
from marimo._ast.parse import ast_parse
44+
from marimo._ast.variables import BUILTINS
45+
from marimo._convert.converters import MarimoConvert
5346
from marimo._messaging.mimetypes import KnownMimeType
5447
from marimo._output.hypertext import Html
5548
from marimo._output.rich_help import mddoc
@@ -65,6 +58,12 @@
6558
FunctionCallRequest,
6659
SetUIElementValueRequest,
6760
)
61+
from marimo._schemas.serialization import (
62+
AppInstantiation,
63+
CellDef,
64+
NotebookSerializationV1,
65+
)
66+
from marimo._types.ids import CellId_t
6867

6968
if TYPE_CHECKING:
7069
from collections.abc import Sequence

marimo/_ast/cell_manager.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22
from __future__ import annotations
33

44
import os
5-
import sys
65
from typing import (
76
TYPE_CHECKING,
87
Callable,
98
Optional,
9+
ParamSpec,
10+
TypeAlias,
1011
TypeVar,
1112
)
1213

13-
if sys.version_info < (3, 10):
14-
from typing_extensions import ParamSpec, TypeAlias
15-
else:
16-
from typing import ParamSpec, TypeAlias
17-
1814
from marimo import _loggers
1915
from marimo._ast.cell import Cell, CellConfig
2016
from marimo._ast.cell_id import CellIdGenerator
@@ -44,7 +40,7 @@
4440
R = TypeVar("R")
4541
Fn: TypeAlias = Callable[P, R]
4642
Cls: TypeAlias = type
47-
Obj: TypeAlias = "Cls | Fn[P, R]"
43+
Obj: TypeAlias = Cls | Fn[P, R]
4844

4945
LOGGER = _loggers.marimo_logger()
5046

marimo/_ast/codegen.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import ast
55
import os
66
import re
7-
import sys
87
import textwrap
98
from typing import TYPE_CHECKING, Any, Literal, Optional
109

@@ -25,10 +24,7 @@
2524
if TYPE_CHECKING:
2625
from pathlib import Path
2726

28-
if sys.version_info < (3, 10):
29-
from typing_extensions import TypeAlias
30-
else:
31-
from typing import TypeAlias
27+
from typing import TypeAlias
3228

3329
Cls: TypeAlias = type
3430

marimo/_ast/compiler.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
import linecache
99
import os
1010
import re
11-
import sys
1211
import textwrap
1312
import token as token_types
1413
import warnings
1514
from tokenize import tokenize
1615
from types import CodeType, FrameType
17-
from typing import Any, Callable, Optional, cast
16+
from typing import Any, Callable, Optional, TypeAlias, cast
1817

1918
from marimo import _loggers
2019
from marimo._ast import parse
@@ -32,11 +31,6 @@
3231
from marimo._types.ids import CellId_t
3332
from marimo._utils.tmpdir import get_tmpdir
3433

35-
if sys.version_info < (3, 10):
36-
from typing_extensions import TypeAlias
37-
else:
38-
from typing import TypeAlias
39-
4034
LOGGER = _loggers.marimo_logger()
4135
Cls: TypeAlias = type
4236

marimo/_ast/visitor.py

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,52 +1034,49 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> ast.ImportFrom:
10341034
)
10351035
return node
10361036

1037-
if sys.version_info >= (3, 10):
1038-
# Match statements were introduced in Python 3.10
1039-
#
1040-
# Top-level match statements are awkward in marimo --- at parse-time,
1041-
# we have to register all names in every case/pattern as globals (since
1042-
# we don't know the value of the match subject), even though only a
1043-
# subset of the names will be bound at runtime. For this reason, in
1044-
# marimo, match statements should really only be used in local scopes.
1045-
def visit_MatchAs(self, node: ast.MatchAs) -> ast.MatchAs:
1046-
if node.name is not None:
1047-
node.name = self._if_local_then_mangle(node.name)
1048-
self._define(
1049-
node,
1050-
node.name,
1051-
VariableData(kind="variable"),
1052-
)
1053-
if node.pattern is not None:
1054-
# pattern may contain additional MatchAs statements in it
1055-
self.visit(node.pattern)
1056-
return node
1037+
# Match statements were introduced in Python 3.10
1038+
#
1039+
# Top-level match statements are awkward in marimo --- at parse-time,
1040+
# we have to register all names in every case/pattern as globals (since
1041+
# we don't know the value of the match subject), even though only a
1042+
# subset of the names will be bound at runtime. For this reason, in
1043+
# marimo, match statements should really only be used in local scopes.
1044+
def visit_MatchAs(self, node: ast.MatchAs) -> ast.MatchAs:
1045+
if node.name is not None:
1046+
node.name = self._if_local_then_mangle(node.name)
1047+
self._define(
1048+
node,
1049+
node.name,
1050+
VariableData(kind="variable"),
1051+
)
1052+
if node.pattern is not None:
1053+
# pattern may contain additional MatchAs statements in it
1054+
self.visit(node.pattern)
1055+
return node
10571056

1058-
def visit_MatchMapping(
1059-
self, node: ast.MatchMapping
1060-
) -> ast.MatchMapping:
1061-
if node.rest is not None:
1062-
node.rest = self._if_local_then_mangle(node.rest)
1063-
self._define(
1064-
node,
1065-
node.rest,
1066-
VariableData(kind="variable"),
1067-
)
1068-
for key in node.keys:
1069-
self.visit(key)
1070-
for pattern in node.patterns:
1071-
self.visit(pattern)
1072-
return node
1057+
def visit_MatchMapping(self, node: ast.MatchMapping) -> ast.MatchMapping:
1058+
if node.rest is not None:
1059+
node.rest = self._if_local_then_mangle(node.rest)
1060+
self._define(
1061+
node,
1062+
node.rest,
1063+
VariableData(kind="variable"),
1064+
)
1065+
for key in node.keys:
1066+
self.visit(key)
1067+
for pattern in node.patterns:
1068+
self.visit(pattern)
1069+
return node
10731070

1074-
def visit_MatchStar(self, node: ast.MatchStar) -> ast.MatchStar:
1075-
if node.name is not None:
1076-
node.name = self._if_local_then_mangle(node.name)
1077-
self._define(
1078-
node,
1079-
node.name,
1080-
VariableData(kind="variable"),
1081-
)
1082-
return node
1071+
def visit_MatchStar(self, node: ast.MatchStar) -> ast.MatchStar:
1072+
if node.name is not None:
1073+
node.name = self._if_local_then_mangle(node.name)
1074+
self._define(
1075+
node,
1076+
node.name,
1077+
VariableData(kind="variable"),
1078+
)
1079+
return node
10831080

10841081
if sys.version_info >= (3, 12):
10851082

marimo/_cli/development/commands.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,6 @@ def inline_packages(name: Path) -> None:
452452
if not name.exists():
453453
raise click.FileError(str(name))
454454

455-
# Validate >=3.10 for sys.stdlib_module_names
456-
if sys.version_info < (3, 10):
457-
# TOD: add support for < 3.10
458-
# We can use https://github.com/omnilib/stdlibs
459-
# to get the stdlib module names
460-
raise click.UsageError("Requires Python >=3.10")
461-
462455
package_names = module_name_to_pypi_name()
463456

464457
def get_pypi_package_names() -> list[str]:

marimo/_convert/ipynb.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,17 @@ def rename_named_node(
404404
name = node.name
405405
new_name = self._maybe_rename(cell, name, is_reference)
406406
node.name = new_name
407-
if sys.version_info >= (3, 10):
408-
if isinstance(node, (ast.MatchAs, ast.MatchStar)):
409-
name = node.name
410-
if name is not None:
411-
new_name = self._maybe_rename(cell, name, is_reference)
412-
node.name = new_name
413-
elif isinstance(node, ast.MatchMapping):
414-
name = node.rest
415-
if name is not None:
416-
new_name = self._maybe_rename(cell, name, is_reference)
417-
node.rest = new_name
407+
408+
if isinstance(node, (ast.MatchAs, ast.MatchStar)):
409+
name = node.name
410+
if name is not None:
411+
new_name = self._maybe_rename(cell, name, is_reference)
412+
node.name = new_name
413+
elif isinstance(node, ast.MatchMapping):
414+
name = node.rest
415+
if name is not None:
416+
new_name = self._maybe_rename(cell, name, is_reference)
417+
node.rest = new_name
418418
if sys.version_info >= (3, 12):
419419
if isinstance(
420420
node, (ast.TypeVar, ast.ParamSpec, ast.TypeVarTuple)

marimo/_messaging/ops.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,14 @@ class ColumnPreview(msgspec.Struct):
613613
stats: Optional[ColumnStats] = None
614614

615615

616-
# We shouldn't need to make table_name and column_name have default values.
617-
# We can use kw_only=True once we drop support for Python 3.9 (25-11-01).
618-
class DataColumnPreview(Op, ColumnPreview, tag="data-column-preview"):
616+
class DataColumnPreview(
617+
Op, ColumnPreview, kw_only=True, tag="data-column-preview"
618+
):
619619
"""Preview of a column in a dataset."""
620620

621621
name: ClassVar[str] = "data-column-preview"
622-
table_name: str = ""
623-
column_name: str = ""
622+
table_name: str
623+
column_name: str
624624

625625

626626
class DataSourceConnections(Op, tag="data-source-connections"):

marimo/_plugins/core/web_component.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,8 @@
1717
from marimo._output.mime import MIME
1818

1919
if TYPE_CHECKING:
20-
import sys
2120
from collections.abc import Mapping, Sequence
22-
23-
if sys.version_info < (3, 10):
24-
from typing_extensions import TypeAlias
25-
else:
26-
from typing import TypeAlias
27-
28-
from typing import Optional
21+
from typing import Optional, TypeAlias
2922

3023
JSONType: TypeAlias = Union[
3124
Mapping[str, "JSONType"],

marimo/_plugins/ui/_core/registry.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
# Copyright 2024 Marimo. All rights reserved.
22
from __future__ import annotations
33

4-
import sys
54
import weakref
6-
from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union
7-
8-
from marimo._runtime.context.types import ContextNotInitializedError
9-
10-
if sys.version_info < (3, 10):
11-
from typing_extensions import TypeAlias
12-
else:
13-
from typing import TypeAlias
5+
from typing import TYPE_CHECKING, Any, Optional, TypeAlias, TypeVar
146

157
from marimo._ast.app import _Namespace
168
from marimo._plugins.ui._core.ui_element import UIElement
179
from marimo._runtime.context import get_context
10+
from marimo._runtime.context.types import ContextNotInitializedError
1811
from marimo._types.ids import CellId_t, UIElementId
1912

2013
if TYPE_CHECKING:
2114
from collections.abc import Iterable, Mapping
2215

2316
T = TypeVar("T")
2417

25-
# Recursive types don't support | or dict[] in py3.8/3.9 (25-11-01)
26-
LensValue: TypeAlias = Union[T, dict[str, "LensValue[T]"]]
18+
LensValue: TypeAlias = T | dict[str, "LensValue[T]"]
2719

2820

2921
class UIElementRegistry:

0 commit comments

Comments
 (0)