[Python-checkins] gh-98576: Fix types in dataclass.InitVar example (gh-98577)

miss-islington webhook-mailer at python.org
Mon Oct 31 11:09:00 EDT 2022


https://github.com/python/cpython/commit/1907e5a7cca9b7348f76c3f1128058ddc4623f22
commit: 1907e5a7cca9b7348f76c3f1128058ddc4623f22
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-10-31T08:08:54-07:00
summary:

gh-98576: Fix types in dataclass.InitVar example (gh-98577)

(cherry picked from commit 880bafc574bcd811dd7244f9a82056430b489996)

Co-authored-by: Shantanu <12621235+hauntsaninja at users.noreply.github.com>

files:
M Doc/library/dataclasses.rst

diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index 02de64288d0d..f66010082ad1 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -561,8 +561,8 @@ value is not provided when creating the class::
   @dataclass
   class C:
       i: int
-      j: int = None
-      database: InitVar[DatabaseType] = None
+      j: int | None = None
+      database: InitVar[DatabaseType | None] = None
 
       def __post_init__(self, database):
           if self.j is None and database is not None:



More information about the Python-checkins mailing list