Skip to content

Commit 0d492a6

Browse files
authored
Fix genericalias parameters (#5841)
* genericalias * Fix attr_exceptions list * impl TypeVarTuple iter * Update _collections_abc.py to Python 3.13 * genericalias.__unpack__
1 parent 3031d5b commit 0d492a6

File tree

11 files changed

+193
-197
lines changed

11 files changed

+193
-197
lines changed

Lib/_collections_abc.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def _f(): pass
8585
dict_items = type({}.items())
8686
## misc ##
8787
mappingproxy = type(type.__dict__)
88+
def _get_framelocalsproxy():
89+
return type(sys._getframe().f_locals)
90+
framelocalsproxy = _get_framelocalsproxy()
91+
del _get_framelocalsproxy
8892
generator = type((lambda: (yield))())
8993
## coroutine ##
9094
async def _coro(): pass
@@ -836,6 +840,7 @@ def __eq__(self, other):
836840
__reversed__ = None
837841

838842
Mapping.register(mappingproxy)
843+
Mapping.register(framelocalsproxy)
839844

840845

841846
class MappingView(Sized):
@@ -973,7 +978,7 @@ def clear(self):
973978

974979
def update(self, other=(), /, **kwds):
975980
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
976-
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
981+
If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k]
977982
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
978983
In either case, this is followed by: for k, v in F.items(): D[k] = v
979984
'''

Lib/test/test_dataclasses.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,8 +1906,6 @@ def new_method(self):
19061906
c = Alias(10, 1.0)
19071907
self.assertEqual(c.new_method(), 1.0)
19081908

1909-
# TODO: RUSTPYTHON
1910-
@unittest.expectedFailure
19111909
def test_generic_dynamic(self):
19121910
T = TypeVar('T')
19131911

Lib/test/test_exception_group.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def test_exception_is_not_generic_type(self):
1515
with self.assertRaisesRegex(TypeError, 'Exception'):
1616
Exception[OSError]
1717

18+
# TODO: RUSTPYTHON
19+
@unittest.expectedFailure
1820
def test_exception_group_is_generic_type(self):
1921
E = OSError
2022
self.assertIsInstance(ExceptionGroup[E], types.GenericAlias)

Lib/test/test_functools.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,8 +2897,6 @@ def _(arg: int | None):
28972897
self.assertEqual(types_union(1), "types.UnionType")
28982898
self.assertEqual(types_union(None), "types.UnionType")
28992899

2900-
# TODO: RUSTPYTHON
2901-
@unittest.expectedFailure
29022900
def test_register_genericalias(self):
29032901
@functools.singledispatch
29042902
def f(arg):
@@ -2918,8 +2916,6 @@ def f(arg):
29182916
self.assertEqual(f(""), "default")
29192917
self.assertEqual(f(b""), "default")
29202918

2921-
# TODO: RUSTPYTHON
2922-
@unittest.expectedFailure
29232919
def test_register_genericalias_decorator(self):
29242920
@functools.singledispatch
29252921
def f(arg):
@@ -2934,8 +2930,6 @@ def f(arg):
29342930
with self.assertRaisesRegex(TypeError, "Invalid first argument to "):
29352931
f.register(typing.List[int] | str)
29362932

2937-
# TODO: RUSTPYTHON
2938-
@unittest.expectedFailure
29392933
def test_register_genericalias_annotation(self):
29402934
@functools.singledispatch
29412935
def f(arg):

Lib/test/test_genericalias.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ def test_exposed_type(self):
173173
self.assertEqual(a.__args__, (int,))
174174
self.assertEqual(a.__parameters__, ())
175175

176-
# TODO: RUSTPYTHON
177-
@unittest.expectedFailure
178176
def test_parameters(self):
179177
from typing import List, Dict, Callable
180178
D0 = dict[str, int]
@@ -214,8 +212,6 @@ def test_parameters(self):
214212
self.assertEqual(L5.__args__, (Callable[[K, V], K],))
215213
self.assertEqual(L5.__parameters__, (K, V))
216214

217-
# TODO: RUSTPYTHON
218-
@unittest.expectedFailure
219215
def test_parameter_chaining(self):
220216
from typing import List, Dict, Union, Callable
221217
self.assertEqual(list[T][int], list[int])
@@ -307,8 +303,6 @@ def test_union(self):
307303
self.assertEqual(a.__args__, (list[int], list[str]))
308304
self.assertEqual(a.__parameters__, ())
309305

310-
# TODO: RUSTPYTHON
311-
@unittest.expectedFailure
312306
def test_union_generic(self):
313307
a = typing.Union[list[T], tuple[T, ...]]
314308
self.assertEqual(a.__args__, (list[T], tuple[T, ...]))

Lib/test/test_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,6 @@ def check(arg, expected):
825825
check(x | None, (x, type(None)))
826826
check(None | x, (type(None), x))
827827

828-
# TODO: RUSTPYTHON
829-
@unittest.expectedFailure
830828
def test_union_parameter_chaining(self):
831829
T = typing.TypeVar("T")
832830
S = typing.TypeVar("S")

0 commit comments

Comments
 (0)