mirror of
https://github.com/python/cpython.git
synced 2025-07-12 22:05:16 +00:00
bpo-33569 Preserve type information with dataclasses.InitVar (GH-8927)
This commit is contained in:
parent
0025350294
commit
01ee12ba35
3 changed files with 17 additions and 3 deletions
|
@ -1097,6 +1097,12 @@ class TestCase(unittest.TestCase):
|
|||
c = C(init_param=10)
|
||||
self.assertEqual(c.x, 20)
|
||||
|
||||
def test_init_var_preserve_type(self):
|
||||
self.assertEqual(InitVar[int].type, int)
|
||||
|
||||
# Make sure the repr is correct.
|
||||
self.assertEqual(repr(InitVar[int]), 'dataclasses.InitVar[int]')
|
||||
|
||||
def test_init_var_inheritance(self):
|
||||
# Note that this deliberately tests that a dataclass need not
|
||||
# have a __post_init__ function if it has an InitVar field.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue