From afe1e543b3433fa821500b34f79c620110262f01 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 9 Jun 2020 21:34:36 +0200 Subject: [PATCH] Make multiprocessing.Namespace accept any attribute (#4204) Update multiprocessing.dummy.Namespace as well Closes: #4186 --- stdlib/3/multiprocessing/dummy/__init__.pyi | 8 +++++--- stdlib/3/multiprocessing/managers.pyi | 5 ++++- tests/stubtest_whitelists/py3_common.txt | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/stdlib/3/multiprocessing/dummy/__init__.pyi b/stdlib/3/multiprocessing/dummy/__init__.pyi index be7ebf99c..5d07f6d9c 100644 --- a/stdlib/3/multiprocessing/dummy/__init__.pyi +++ b/stdlib/3/multiprocessing/dummy/__init__.pyi @@ -25,10 +25,12 @@ class DummyProcess(threading.Thread): Process = DummyProcess -class Namespace(object): - def __init__(self, **kwds) -> None: ... +class Namespace: + def __init__(self, **kwds: Any) -> None: ... + def __getattr__(self, __name: str) -> Any: ... + def __setattr__(self, __name: str, __value: Any) -> None: ... -class Value(object): +class Value: _typecode: Any _value: Any value: Any diff --git a/stdlib/3/multiprocessing/managers.pyi b/stdlib/3/multiprocessing/managers.pyi index 99f441fc8..528a18038 100644 --- a/stdlib/3/multiprocessing/managers.pyi +++ b/stdlib/3/multiprocessing/managers.pyi @@ -18,7 +18,10 @@ _T = TypeVar('_T') _KT = TypeVar('_KT') _VT = TypeVar('_VT') -class Namespace: ... +class Namespace: + def __init__(self, **kwds: Any) -> None: ... + def __getattr__(self, __name: str) -> Any: ... + def __setattr__(self, __name: str, __value: Any) -> None: ... _Namespace = Namespace diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 9e63ff52c..80f35c0d1 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -523,6 +523,8 @@ typing.[A-Z]\w+ # We can't distinguish not having a default value from having a default value of inspect.Parameter.empty inspect.Parameter.__init__ inspect.Signature.__init__ +# Any field can be set on Namespace +multiprocessing.(dummy|managers).Namespace.__[gs]etattr__ os.[a-z]+_(param|result)._(asdict|make|replace) # NamedTuple like, but not actually NamedTuples # sys attributes that are not always defined sys.last_traceback