Skip to content

Commit b6b5a14

Browse files
committed
Remove code to fix dunder attributes -> other PR
1 parent 889e9ae commit b6b5a14

File tree

2 files changed

+3
-37
lines changed

2 files changed

+3
-37
lines changed

src/test_typing_extensions.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7180,40 +7180,6 @@ def test_attributes(self):
71807180
self.assertEqual(CallableP.__type_params__, (P,))
71817181
self.assertEqual(CallableP.__parameters__, (P,))
71827182

7183-
def test_attributes_from_origin(self):
7184-
T = TypeVar('T')
7185-
ListOrSetT = TypeAliasType("ListOrSetT", Union[List[T], Set[T]], type_params=(T,))
7186-
subscripted = ListOrSetT[int]
7187-
self.assertIs(get_origin(subscripted), ListOrSetT)
7188-
self.assertEqual(subscripted.__name__, "ListOrSetT")
7189-
self.assertEqual(subscripted.__value__, Union[List[T], Set[T]],)
7190-
self.assertEqual(subscripted.__type_params__, (T, ))
7191-
7192-
still_generic = ListOrSetT[Iterable[T]]
7193-
self.assertIs(get_origin(still_generic), ListOrSetT)
7194-
fully_subscripted = still_generic[float]
7195-
self.assertIs(get_origin(fully_subscripted), ListOrSetT)
7196-
# __name__ needs Python 3.10+
7197-
# __value__ and __type_params__ need Python 3.12+
7198-
# Further tests are below
7199-
7200-
@skipUnless(TYPING_3_10_0, "__name__ not added to GenericAlias")
7201-
def test_attributes_from_origin_3_10_plus(self):
7202-
T = TypeVar('T')
7203-
ListOrSetT = TypeAliasType("ListOrSetT", Union[List[T], Set[T]], type_params=(T,))
7204-
fully_subscripted = ListOrSetT[Iterable[T]][float]
7205-
self.assertEqual(fully_subscripted.__name__, "ListOrSetT")
7206-
# __value__ and __type_params__ need Python 3.12+
7207-
7208-
@skipUnless(TYPING_3_12_0, "attributes not added to GenericAlias")
7209-
def test_attributes_from_origin_3_12_plus(self):
7210-
T = TypeVar('T')
7211-
ListOrSetT = TypeAliasType("ListOrSetT", Union[List[T], Set[T]], type_params=(T,))
7212-
fully_subscripted = ListOrSetT[Iterable[T]][float]
7213-
self.assertEqual(fully_subscripted.__name__, "ListOrSetT")
7214-
self.assertEqual(fully_subscripted.__value__, Union[List[T], Set[T]],)
7215-
self.assertEqual(fully_subscripted.__type_params__, (T, ))
7216-
72177183
def test_alias_types_and_substitutions(self):
72187184
T = TypeVar('T')
72197185
T2 = TypeVar('T2')
@@ -7359,13 +7325,16 @@ def test_getitem(self):
73597325
ListOrSetT = TypeAliasType("ListOrSetT", Union[List[T], Set[T]], type_params=(T,))
73607326
subscripted = ListOrSetT[int]
73617327
self.assertEqual(get_args(subscripted), (int,))
7328+
self.assertIs(get_origin(subscripted), ListOrSetT)
73627329
with self.assertRaises(TypeError, msg="not a generic class"):
73637330
subscripted[int]
73647331

73657332
still_generic = ListOrSetT[Iterable[T]]
73667333
self.assertEqual(get_args(still_generic), (Iterable[T],))
7334+
self.assertIs(get_origin(still_generic), ListOrSetT)
73677335
fully_subscripted = still_generic[float]
73687336
self.assertEqual(get_args(fully_subscripted), (Iterable[float],))
7337+
self.assertIs(get_origin(fully_subscripted), ListOrSetT)
73697338

73707339
def test_callable_without_concatenate(self):
73717340
P = ParamSpec('P')

src/typing_extensions.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,9 +3564,6 @@ def __getitem__(self, parameters):
35643564
alias = typing._GenericAlias(self, tuple(parameters))
35653565
if len(alias.__parameters__) < len(type_vars):
35663566
alias.__parameters__ = tuple(type_vars)
3567-
alias.__value__ = self.__value__
3568-
alias.__type_params__ = self.__type_params__
3569-
alias.__name__ = self.__name__
35703567
return alias
35713568

35723569
def __reduce__(self):

0 commit comments

Comments
 (0)