Skip to content

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.

refactor: type Python inspection helper inputs (#11379)

Shahmir Varqha68d03e2df95e
diff --git a/marimo/_utils/hashable.py b/marimo/_utils/hashable.py
index 1b20074896..91d9dc9785 100644
--- a/marimo/_utils/hashable.py
+++ b/marimo/_utils/hashable.py
@@ -1,10 +1,8 @@
# Copyright 2026 Marimo. All rights reserved.
from __future__ import annotations
-from typing import Any
-
-def is_hashable(*values: Any) -> bool:
+def is_hashable(*values: object) -> bool:
"""
Check if all values passed in are hashable.
"""
diff --git a/marimo/_utils/repr.py b/marimo/_utils/repr.py
index cae242336f..871b9a1edf 100644
--- a/marimo/_utils/repr.py
+++ b/marimo/_utils/repr.py
@@ -1,10 +1,13 @@
# Copyright 2026 Marimo. All rights reserved.
from __future__ import annotations
-from typing import Any
+from typing import TYPE_CHECKING
+if TYPE_CHECKING:
+ from collections.abc import Mapping
-def format_repr(obj: Any, items: dict[str, Any]) -> str:
+
+def format_repr(obj: object, items: Mapping[str, object]) -> str:
"""Format a repr string."""
kvs = [f"{k}={v}" for k, v in items.items()]
return f"{obj.__class__.__name__}({', '.join(kvs)})"
diff --git a/marimo/_utils/site_packages.py b/marimo/_utils/site_packages.py
index 31aff9b41c..8b0bdc2b1d 100644
--- a/marimo/_utils/site_packages.py
+++ b/marimo/_utils/site_packages.py
@@ -5,7 +5,10 @@ import functools
import os
import pathlib
import site
-from typing import Any
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from importlib.machinery import ModuleSpec
@functools.cache
@@ -23,7 +26,7 @@ def _getsitepackages() -> list[pathlib.Path]:
return site_packages_dirs
-def is_local_module(spec: Any) -> bool:
+def is_local_module(spec: ModuleSpec | None) -> bool:
"""Check if a module is local (not under site-packages).
Uses Python's site module to get actual site-packages directories,