8000 Merge pull request #5909 from youknowone/typing-parameters · RustPython/RustPython@ec577e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit ec577e5

Browse files
authored
Merge pull request #5909 from youknowone/typing-parameters
typing __parameters__ __type_params__
2 parents 7ebe018 + bd54e53 commit ec577e5

20 files changed

+295
-322
lines changed

Lib/test/_typed_dict_helper.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

Lib/test/ann_module.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

Lib/test/ann_module2.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

Lib/test/ann_module3.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

Lib/test/ann_module4.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

Lib/test/ann_module5.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

Lib/test/ann_module6.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

Lib/test/ann_module7.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

Lib/test/mod_generics_cache.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

Lib/test/test_grammar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def test_var_annot_module_semantics(self):
400400
def test_var_annot_in_module(self):
401401
# check that functions fail the same way when executed
402402
# outside of module where they were defined
403-
from test.ann_module3 import f_bad_ann, g_bad_ann, D_bad_ann
403+
from test.typinganndata.ann_module3 import f_bad_ann, g_bad_ann, D_bad_ann
404404
with self.assertRaises(NameError):
405405
f_bad_ann()
406406
with self.assertRaises(NameError):

Lib/test/test_module/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def test_annotations_getset_raises(self):
334334
del foo.__annotations__
335335

336336
def test_annotations_are_created_correctly(self):
337-
ann_module4 = import_helper.import_fresh_module('test.ann_module4')
337+
ann_module4 = import_helper.import_fresh_module('test.typinganndata.ann_module4')
338338
self.assertTrue("__annotations__" in ann_module4.__dict__)
339339
del ann_module4.__annotations__
340340
self.assertFalse("__annotations__" in ann_module4.__dict__)

Lib/test/test_typing.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,6 @@ def test_typevar(self):
629629
class A(Generic[T]): ...
630630
Alias = Optional[T]
631631

632-
# TODO: RUSTPYTHON
633-
@unittest.expectedFailure
634632
def test_typevar_none(self):
635633
U = TypeVar('U')
636634
U_None = TypeVar('U_None', default=None)
@@ -1210,8 +1208,6 @@ def foo(**kwargs: Unpack[Movie]): ...
12101208
self.assertEqual(repr(foo.__annotations__['kwargs']),
12111209
f"typing.Unpack[{__name__}.Movie]")
12121210

1213-
# TODO: RUSTPYTHON
1214-
@unittest.expectedFailure
12151211
def test_builtin_tuple(self):
12161212
Ts = TypeVarTuple("Ts")
12171213

@@ -2636,11 +2632,6 @@ def test_consistency(self):
26362632
class CollectionsCallableTests(BaseCallableTests, BaseTestCase):
26372633
Callable = collections.abc.Callable
26382634

2639-
# TODO: RUSTPYTHON
2640-
@unittest.expectedFailure
2641-
def test_errors(self):
2642-
super().test_errors()
2643-
26442635

26452636
class LiteralTests(BaseTestCase):
26462637
def test_basics(self):
@@ -3608,8 +3599,6 @@ class C(B[int]):
36083599
c.bar = 'abc'
36093600
self.assertEqual(c.__dict__, {'bar': 'abc'})
36103601

3611-
# TODO: RUSTPYTHON
3612-
@unittest.expectedFailure
36133602
def test_setattr_exceptions(self):
36143603
class Immutable[T]:
36153604
def __setattr__(self, key, value):
@@ -3753,8 +3742,6 @@ class Meta(type): ...
37533742
self.assertEqual(Union[T, int][Meta], Union[Meta, int])
37543743
self.assertEqual(Callable[..., Meta].__args__, (Ellipsis, Meta))
37553744

3756-
# TODO: RUSTPYTHON
3757-
@unittest.expectedFailure
37583745
def test_generic_hashes(self):
37593746
class A(Generic[T]):
37603747
...
@@ -4302,8 +4289,6 @@ class B(Generic[T]):
43024289
self.assertEqual(A[T], A[T])
43034290
self.assertNotEqual(A[T], B[T])
43044291

4305-
# TODO: RUSTPYTHON
4306-
@unittest.expectedFailure
43074292
def test_multiple_inheritance(self):
43084293

43094294
class A(Generic[T, VT]):
@@ -6106,8 +6091,6 @@ class C(Generic[T]): pass
61066091
self.assertIs(get_origin((*tuple[*Ts],)[0]), tuple)
61076092
self.assertIs(get_origin(Unpack[Tuple[Unpack[Ts]]]), Unpack)
61086093

6109-
# TODO: RUSTPYTHON
6110-
@unittest.expectedFailure
61116094
def test_get_args(self):
61126095
T = TypeVar('T')
61136096
class C(Generic[T]): pass
@@ -7599,8 +7582,6 @@ class A[T](TypedDict):
75997582
self.assertEqual(A[str].__parameters__, ())
76007583
self.assertEqual(A[str].__args__, (str,))
76017584

7602-
# TODO: RUSTPYTHON
7603-
@unittest.expectedFailure
76047585
def test_generic_inheritance(self):
76057586
class A(TypedDict, Generic[T]):
76067587
a: T

Lib/test/typinganndata/mod_generics_cache.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22

33
from typing import TypeVar, Generic, Optional, TypeAliasType
44

5-
# TODO: RUSTPYTHON
5+
default_a: Optional['A'] = None
6+
default_b: Optional['B'] = None
67

7-
# default_a: Optional['A'] = None
8-
# default_b: Optional['B'] = None
8+
T = TypeVar('T')
99

10-
# T = TypeVar('T')
1110

11+
class A(Generic[T]):
12+
some_b: 'B'
1213

13-
# class A(Generic[T]):
14-
# some_b: 'B'
1514

15+
class B(Generic[T]):
16+
class A(Generic[T]):
17+
pass
1618

17-
# class B(Generic[T]):
18-
# class A(Generic[T]):
19-
# pass
19+
my_inner_a1: 'B.A'
20+
my_inner_a2: A
21+
my_outer_a: 'A' # unless somebody calls get_type_hints with localns=B.__dict__
2022

21-
# my_inner_a1: 'B.A'
22-
# my_inner_a2: A
23-
# my_outer_a: 'A' # unless somebody calls get_type_hints with localns=B.__dict__
24-
25-
# type Alias = int
26-
# OldStyle = TypeAliasType("OldStyle", int)
23+
type Alias = int
24+
OldStyle = TypeAliasType("OldStyle", int)

0 commit comments

Comments
 (0)
0