From 160c26188911916175a2467f4f13cb55bf5d2891 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 30 Jul 2021 20:57:14 -0700 Subject: [PATCH 1/3] 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 519da6d31dbe..936197cae90e 100644 --- a/stdlib/dataclasses.pyi +++ b/stdlib/dataclasses.pyi @@ -14,7 +14,7 @@ MISSING: _MISSING_TYPE if sys.version_info >= (3, 10): class _KW_ONLY_TYPE: ... - KW_ONLY: _KW_ONLY_TYPE + KW_ONLY = _KW_ONLY_TYPE @overload def asdict(obj: Any) -> Dict[str, Any]: ... From 7492912d847fc4afad06b51c8c58988bc4e8c276 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 30 Jul 2021 21:06:53 -0700 Subject: [PATCH 2/3] PR feedback... --- stdlib/dataclasses.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/dataclasses.pyi b/stdlib/dataclasses.pyi index 936197cae90e..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]: ... From 5007a768fc9859f3fde06e996a014e853641ba23 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 1 Aug 2021 07:52:41 -0700 Subject: [PATCH 3/3] Added dataclasses.KW_ONLY to the allowlist to make CI pass --- tests/stubtest_allowlists/py310.txt | 1 + 1 file changed, 1 insertion(+) 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