mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-104600: Make function.__type_params__ writable (#104601)
This commit is contained in:
parent
f7835fc7e9
commit
3fadd7d585
6 changed files with 39 additions and 5 deletions
|
@ -617,7 +617,7 @@ class TestUpdateWrapper(unittest.TestCase):
|
|||
|
||||
|
||||
def _default_update(self):
|
||||
def f(a:'This is a new annotation'):
|
||||
def f[T](a:'This is a new annotation'):
|
||||
"""This is a test"""
|
||||
pass
|
||||
f.attr = 'This is also a test'
|
||||
|
@ -630,12 +630,14 @@ class TestUpdateWrapper(unittest.TestCase):
|
|||
def test_default_update(self):
|
||||
wrapper, f = self._default_update()
|
||||
self.check_wrapper(wrapper, f)
|
||||
T, = f.__type_params__
|
||||
self.assertIs(wrapper.__wrapped__, f)
|
||||
self.assertEqual(wrapper.__name__, 'f')
|
||||
self.assertEqual(wrapper.__qualname__, f.__qualname__)
|
||||
self.assertEqual(wrapper.attr, 'This is also a test')
|
||||
self.assertEqual(wrapper.__annotations__['a'], 'This is a new annotation')
|
||||
self.assertNotIn('b', wrapper.__annotations__)
|
||||
self.assertEqual(wrapper.__type_params__, (T,))
|
||||
|
||||
@unittest.skipIf(sys.flags.optimize >= 2,
|
||||
"Docstrings are omitted with -O2 and above")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue