8000 GH-103699: Add `__orig_bases__` to various typing classes by adriangb · Pull Request #103698 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-103699: Add __orig_bases__ to various typing classes #103698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 23, 2023
Prev Previous commit
Next Next commit
add more test cases
  • Loading branch information
adriangb committed Apr 23, 2023
commit 19569f901ca2c4711c13c02afde42fd65871f962
35 changes: 34 additions & 1 deletion Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7127,7 +7127,40 @@ class TD(TypedDict):
self.assertEqual(a, {'a': 1})

def test_orig_bases(self):
self.assertEqual(ChildTotalMovie.__orig_bases__, (ParentNontotalMovie,))
T = TypeVar('T')

class Parent(TypedDict):
pass

class Child(Parent):
pass

class OtherChild(Parent):
pass

class MixedChild(Child, OtherChild, Parent):
pass

class GenericParent(TypedDict, Generic[T]):
pass

class GenericChild(GenericParent[int]):
pass

class OtherGenericChild(GenericParent[str]):
pass

class MixedGenericChild(GenericChild, OtherGenericChild, GenericParent[float]):
pass

self.assertEqual(Parent.__orig_bases__, (TypedDict,))
self.assertEqual(Child.__orig_bases__, (Parent,))
self.assertEqual(OtherChild.__orig_bases__, (Parent,))
self.assertEqual(MixedChild.__orig_bases__, (Child, OtherChild, Parent,))
self.assertEqual(GenericParent.__orig_bases__, (TypedDict, Generic[T]))
self.assertEqual(GenericChild.__orig_bases__, (GenericParent[int],))
self.assertEqual(OtherGenericChild.__orig_bases__, (GenericParent[str],))
self.assertEqual(MixedGenericChild.__orig_bases__, (GenericChild, OtherGenericChild, GenericParent[float]))


class RequiredTests(BaseTestCase):
Expand Down
0