mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
gh-118814: Fix the TypeVar constructor when name is passed by keyword (GH-122664)
Fix _PyArg_UnpackKeywordsWithVararg for the case when argument for positional-or-keyword parameter is passed by keyword. There was only one such case in the stdlib -- the TypeVar constructor.
This commit is contained in:
parent
e73e7a7abd
commit
540fcc62f5
6 changed files with 165 additions and 7 deletions
|
@ -579,6 +579,55 @@ class TypeVarTests(BaseTestCase):
|
|||
self.assertEqual(T.__name__, "T")
|
||||
self.assertEqual(T.__constraints__, ())
|
||||
self.assertIs(T.__bound__, None)
|
||||
self.assertIs(T.__default__, typing.NoDefault)
|
||||
self.assertIs(T.__covariant__, False)
|
||||
self.assertIs(T.__contravariant__, False)
|
||||
self.assertIs(T.__infer_variance__, False)
|
||||
|
||||
T = TypeVar(name="T", bound=type)
|
||||
self.assertEqual(T.__name__, "T")
|
||||
self.assertEqual(T.__constraints__, ())
|
||||
self.assertIs(T.__bound__, type)
|
||||
self.assertIs(T.__default__, typing.NoDefault)
|
||||
self.assertIs(T.__covariant__, False)
|
||||
self.assertIs(T.__contravariant__, False)
|
||||
self.assertIs(T.__infer_variance__, False)
|
||||
|
||||
T = TypeVar(name="T", default=())
|
||||
self.assertEqual(T.__name__, "T")
|
||||
self.assertEqual(T.__constraints__, ())
|
||||
self.assertIs(T.__bound__, None)
|
||||
self.assertIs(T.__default__, ())
|
||||
self.assertIs(T.__covariant__, False)
|
||||
self.assertIs(T.__contravariant__, False)
|
||||
self.assertIs(T.__infer_variance__, False)
|
||||
|
||||
T = TypeVar(name="T", covariant=True)
|
||||
self.assertEqual(T.__name__, "T")
|
||||
self.assertEqual(T.__constraints__, ())
|
||||
self.assertIs(T.__bound__, None)
|
||||
self.assertIs(T.__default__, typing.NoDefault)
|
||||
self.assertIs(T.__covariant__, True)
|
||||
self.assertIs(T.__contravariant__, False)
|
||||
self.assertIs(T.__infer_variance__, False)
|
||||
|
||||
T = TypeVar(name="T", contravariant=True)
|
||||
self.assertEqual(T.__name__, "T")
|
||||
self.assertEqual(T.__constraints__, ())
|
||||
self.assertIs(T.__bound__, None)
|
||||
self.assertIs(T.__default__, typing.NoDefault)
|
||||
self.assertIs(T.__covariant__, False)
|
||||
self.assertIs(T.__contravariant__, True)
|
||||
self.assertIs(T.__infer_variance__, False)
|
||||
|
||||
T = TypeVar(name="T", infer_variance=True)
|
||||
self.assertEqual(T.__name__, "T")
|
||||
self.assertEqual(T.__constraints__, ())
|
||||
self.assertIs(T.__bound__, None)
|
||||
self.assertIs(T.__default__, typing.NoDefault)
|
||||
self.assertIs(T.__covariant__, False)
|
||||
self.assertIs(T.__contravariant__, False)
|
||||
self.assertIs(T.__infer_variance__, True)
|
||||
|
||||
|
||||
class TypeParameterDefaultsTests(BaseTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue