Skip to content

Commit 4ceebbc

Browse files
authored
Fix shared type in _interpreters (#14328)
1 parent b532f6b commit 4ceebbc

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

stdlib/_interpreters.pyi

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import types
2-
from collections.abc import Callable, Mapping
3-
from typing import Final, Literal, SupportsIndex
2+
from collections.abc import Callable
3+
from typing import Any, Final, Literal, SupportsIndex
44
from typing_extensions import TypeAlias
55

66
_Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
7+
_SharedDict: TypeAlias = dict[str, Any] # many objects can be shared
78

89
class InterpreterError(Exception): ...
910
class InterpreterNotFoundError(InterpreterError): ...
@@ -22,7 +23,11 @@ def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool: ...
2223
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace: ...
2324
def whence(id: SupportsIndex) -> int: ...
2425
def exec(
25-
id: SupportsIndex, code: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
26+
id: SupportsIndex,
27+
code: str | types.CodeType | Callable[[], object],
28+
shared: _SharedDict | None = None,
29+
*,
30+
restrict: bool = False,
2631
) -> None | types.SimpleNamespace: ...
2732
def call(
2833
id: SupportsIndex,
@@ -33,12 +38,16 @@ def call(
3338
restrict: bool = False,
3439
) -> object: ...
3540
def run_string(
36-
id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
41+
id: SupportsIndex,
42+
script: str | types.CodeType | Callable[[], object],
43+
shared: _SharedDict | None = None,
44+
*,
45+
restrict: bool = False,
3746
) -> None: ...
3847
def run_func(
39-
id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: bool | None = None, *, restrict: bool = False
48+
id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: _SharedDict | None = None, *, restrict: bool = False
4049
) -> None: ...
41-
def set___main___attrs(id: SupportsIndex, updates: Mapping[str, object], *, restrict: bool = False) -> None: ...
50+
def set___main___attrs(id: SupportsIndex, updates: _SharedDict, *, restrict: bool = False) -> None: ...
4251
def incref(id: SupportsIndex, *, implieslink: bool = False, restrict: bool = False) -> None: ...
4352
def decref(id: SupportsIndex, *, restrict: bool = False) -> None: ...
4453
def is_shareable(obj: object) -> bool: ...

0 commit comments

Comments
 (0)