From ea4be02bab2123dd33631f407d4ff32e123fa8fb Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 1 Aug 2021 08:06:48 -0700 Subject: [PATCH] Redefined dataclasses.KW_ONLY (#5826) Redefined dataclasses.KW_ONLY so it's a type alias rather than a class instance. Class instances are illegal to use within a type annotation. --- stdlib/dataclasses.pyi | 3 +-- tests/stubtest_allowlists/py310.txt | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 519da6d31dbe..bf824abaf4e5 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -13,8 +13,7 @@ class _MISSING_TYPE: ... MISSING: _MISSING_TYPE if sys.version_info >= (3, 10): - class _KW_ONLY_TYPE: ... - KW_ONLY: _KW_ONLY_TYPE + class KW_ONLY: ... @overload def asdict(obj: Any) -> Dict[str, Any]: ... diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 0adf00e64a73..e7f1884e7291 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -37,6 +37,7 @@ collections.abc.KeysView.__reversed__ collections.abc.ValuesView.__reversed__ contextvars.Context.__init__ # Default C __init__ signature is wrong dataclasses.field +dataclasses.KW_ONLY dummy_threading enum.Enum._generate_next_value_ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve