mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Added kw_only parameter to make_dataclasses. (GH-29679)
This commit is contained in:
parent
fdc0e09c33
commit
f7638dd0f9
3 changed files with 14 additions and 2 deletions
|
|
@ -3864,5 +3864,16 @@ class TestKeywordArgs(unittest.TestCase):
|
|||
c: int = 1
|
||||
d: int
|
||||
|
||||
def test_make_dataclass(self):
|
||||
A = make_dataclass("A", ['a'], kw_only=True)
|
||||
self.assertTrue(fields(A)[0].kw_only)
|
||||
|
||||
B = make_dataclass("B",
|
||||
['a', ('b', int, field(kw_only=False))],
|
||||
kw_only=True)
|
||||
self.assertTrue(fields(B)[0].kw_only)
|
||||
self.assertFalse(fields(B)[1].kw_only)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue