Skip to content

Commit c81d161

Browse files
authored
[multiprocessing] Fix return types of Value and Array (#16485)
1 parent afd3b6d commit c81d161

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎stdlib/multiprocessing/context.pyi‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from multiprocessing import popen_fork, popen_forkserver, popen_spawn_posix, pop
88
from multiprocessing.managers import SyncManager
99
from multiprocessing.pool import Pool as _Pool
1010
from multiprocessing.process import BaseProcess
11-
from multiprocessing.sharedctypes import Synchronized, SynchronizedArray, SynchronizedString
11+
from multiprocessing.sharedctypes import Synchronized, SynchronizedArray, SynchronizedBase, SynchronizedString
1212
from typing import Any, ClassVar, Literal, TypeAlias, TypeVar, overload
1313

1414
if sys.platform != "win32":
@@ -90,18 +90,18 @@ class BaseContext:
9090
self, typecode_or_type: type[_SimpleCData[_T]], *args: Any, lock: Literal[True] | _LockLike = True
9191
) -> Synchronized[_T]: ...
9292
@overload
93-
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[False]) -> Synchronized[_CT]: ...
93+
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[False]) -> _CT: ...
9494
@overload
95-
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = True) -> Synchronized[_CT]: ...
95+
def Value(self, typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = True) -> SynchronizedBase[_CT]: ...
9696
@overload
9797
def Value(self, typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = True) -> Synchronized[Any]: ...
9898
@overload
9999
def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = True) -> Any: ...
100100

101101
@overload
102102
def Array(
103-
self, typecode_or_type: type[_SimpleCData[_T]], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]
104-
) -> SynchronizedArray[_T]: ...
103+
self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]
104+
) -> ctypes.Array[_CT]: ...
105105
@overload
106106
def Array(
107107
self, typecode_or_type: type[c_char], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True

‎stdlib/multiprocessing/sharedctypes.pyi‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ def RawArray(typecode_or_type: str, size_or_initializer: int | Sequence[Any]) ->
2525
@overload
2626
def Value(typecode_or_type: type[_CT], *args: Any, lock: Literal[False], ctx: BaseContext | None = None) -> _CT: ...
2727
@overload
28+
def Value(
29+
typecode_or_type: type[_SimpleCData[_T]], *args: Any, lock: Literal[True] | _LockLike = True, ctx: BaseContext | None = None
30+
) -> Synchronized[_T]: ...
31+
@overload
2832
def Value(
2933
typecode_or_type: type[_CT], *args: Any, lock: Literal[True] | _LockLike = True, ctx: BaseContext | None = None
3034
) -> SynchronizedBase[_CT]: ...
3135
@overload
3236
def Value(
3337
typecode_or_type: str, *args: Any, lock: Literal[True] | _LockLike = True, ctx: BaseContext | None = None
34-
) -> SynchronizedBase[Any]: ...
38+
) -> Synchronized[Any]: ...
3539
@overload
3640
def Value(
3741
typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = True, ctx: BaseContext | None = None
@@ -40,7 +44,7 @@ def Value(
4044
@overload
4145
def Array(
4246
typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False], ctx: BaseContext | None = None
43-
) -> _CT: ...
47+
) -> ctypes.Array[_CT]: ...
4448
@overload
4549
def Array(
4650
typecode_or_type: type[c_char],

0 commit comments

Comments
 (0)