Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d46bcd9

Browse filesBrowse files
authored
typing upgrade to 3.13.2 (#5590)
1 parent ca496fb commit d46bcd9
Copy full SHA for d46bcd9

13 files changed

+7817
-1972
lines changed

‎Lib/_py_abc.py

Copy file name to clipboardExpand all lines: Lib/_py_abc.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class ABCMeta(type):
3333
_abc_invalidation_counter = 0
3434

3535
def __new__(mcls, name, bases, namespace, /, **kwargs):
36+
# TODO: RUSTPYTHON remove this line (prevents duplicate bases)
37+
bases = tuple(dict.fromkeys(bases))
3638
cls = super().__new__(mcls, name, bases, namespace, **kwargs)
3739
# Compute set of abstract method names
3840
abstracts = {name
@@ -98,8 +100,8 @@ def __instancecheck__(cls, instance):
98100
subtype = type(instance)
99101
if subtype is subclass:
100102
if (cls._abc_negative_cache_version ==
101-
ABCMeta._abc_invalidation_counter and
102-
subclass in cls._abc_negative_cache):
103+
ABCMeta._abc_invalidation_counter and
104+
subclass in cls._abc_negative_cache):
103105
return False
104106
# Fall back to the subclass check.
105107
return cls.__subclasscheck__(subclass)

‎Lib/test/support/testcase.py

Copy file name to clipboardExpand all lines: Lib/test/support/testcase.py
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,63 @@
11
from math import copysign, isnan
22

33

4+
class ExtraAssertions:
5+
6+
def assertIsSubclass(self, cls, superclass, msg=None):
7+
if issubclass(cls, superclass):
8+
return
9+
standardMsg = f'{cls!r} is not a subclass of {superclass!r}'
10+
self.fail(self._formatMessage(msg, standardMsg))
11+
12+
def assertNotIsSubclass(self, cls, superclass, msg=None):
13+
if not issubclass(cls, superclass):
14+
return
15+
standardMsg = f'{cls!r} is a subclass of {superclass!r}'
16+
self.fail(self._formatMessage(msg, standardMsg))
17+
18+
def assertHasAttr(self, obj, name, msg=None):
19+
if not hasattr(obj, name):
20+
if isinstance(obj, types.ModuleType):
21+
standardMsg = f'module {obj.__name__!r} has no attribute {name!r}'
22+
elif isinstance(obj, type):
23+
standardMsg = f'type object {obj.__name__!r} has no attribute {name!r}'
24+
else:
25+
standardMsg = f'{type(obj).__name__!r} object has no attribute {name!r}'
26+
self.fail(self._formatMessage(msg, standardMsg))
27+
28+
def assertNotHasAttr(self, obj, name, msg=None):
29+
if hasattr(obj, name):
30+
if isinstance(obj, types.ModuleType):
31+
standardMsg = f'module {obj.__name__!r} has unexpected attribute {name!r}'
32+
elif isinstance(obj, type):
33+
standardMsg = f'type object {obj.__name__!r} has unexpected attribute {name!r}'
34+
else:
35+
standardMsg = f'{type(obj).__name__!r} object has unexpected attribute {name!r}'
36+
self.fail(self._formatMessage(msg, standardMsg))
37+
38+
def assertStartsWith(self, s, prefix, msg=None):
39+
if s.startswith(prefix):
40+
return
41+
standardMsg = f"{s!r} doesn't start with {prefix!r}"
42+
self.fail(self._formatMessage(msg, standardMsg))
43+
44+
def assertNotStartsWith(self, s, prefix, msg=None):
45+
if not s.startswith(prefix):
46+
return
47+
self.fail(self._formatMessage(msg, f"{s!r} starts with {prefix!r}"))
48+
49+
def assertEndsWith(self, s, suffix, msg=None):
50+
if s.endswith(suffix):
51+
return
52+
standardMsg = f"{s!r} doesn't end with {suffix!r}"
53+
self.fail(self._formatMessage(msg, standardMsg))
54+
55+
def assertNotEndsWith(self, s, suffix, msg=None):
56+
if not s.endswith(suffix):
57+
return
58+
self.fail(self._formatMessage(msg, f"{s!r} ends with {suffix!r}"))
59+
60+
461
class ExceptionIsLikeMixin:
562
def assertExceptionIsLike(self, exc, template):
663
"""

‎Lib/test/test_dataclasses.py

Copy file name to clipboardExpand all lines: Lib/test/test_dataclasses.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,8 @@ 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
19091911
def test_generic_dynamic(self):
19101912
T = TypeVar('T')
19111913

@@ -3250,6 +3252,8 @@ def test_classvar_module_level_import(self):
32503252
# won't exist on the instance.
32513253
self.assertNotIn('not_iv4', c.__dict__)
32523254

3255+
# TODO: RUSTPYTHON
3256+
@unittest.expectedFailure
32533257
def test_text_annotations(self):
32543258
from test import dataclass_textanno
32553259

‎Lib/test/test_exception_group.py

Copy file name to clipboardExpand all lines: Lib/test/test_exception_group.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ def test_exception_is_not_generic_type(self):
1515
with self.assertRaisesRegex(TypeError, 'Exception'):
1616
Exception[OSError]
1717

18-
# TODO: RUSTPYTHON
19-
@unittest.expectedFailure
2018
def test_exception_group_is_generic_type(self):
2119
E = OSError
2220
self.assertIsInstance(ExceptionGroup[E], types.GenericAlias)

‎Lib/test/test_future_stmt/test_future.py

Copy file name to clipboardExpand all lines: Lib/test/test_future_stmt/test_future.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,6 @@ def foo():
442442
def bar(arg: (yield)): pass
443443
"""))
444444

445-
# TODO: RUSTPYTHON
446-
@unittest.expectedFailure
447445
def test_get_type_hints_on_func_with_variadic_arg(self):
448446
# `typing.get_type_hints` might break on a function with a variadic
449447
# annotation (e.g. `f(*args: *Ts)`) if `from __future__ import

‎Lib/test/test_genericalias.py

Copy file name to clipboardExpand all lines: Lib/test/test_genericalias.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ def test_exposed_type(self):
173173
self.assertEqual(a.__args__, (int,))
174174
self.assertEqual(a.__parameters__, ())
175175

176+
# TODO: RUSTPYTHON
177+
@unittest.expectedFailure
176178
def test_parameters(self):
177179
from typing import List, Dict, Callable
178180
D0 = dict[str, int]
@@ -212,6 +214,8 @@ def test_parameters(self):
212214
self.assertEqual(L5.__args__, (Callable[[K, V], K],))
213215
self.assertEqual(L5.__parameters__, (K, V))
214216

217+
# TODO: RUSTPYTHON
218+
@unittest.expectedFailure
215219
def test_parameter_chaining(self):
216220
from typing import List, Dict, Union, Callable
217221
self.assertEqual(list[T][int], list[int])
@@ -271,6 +275,8 @@ class MyType(type):
271275
with self.assertRaises(TypeError):
272276
MyType[int]
273277

278+
# TODO: RUSTPYTHON
279+
@unittest.expectedFailure
274280
def test_pickle(self):
275281
alias = GenericAlias(list, T)
276282
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -280,6 +286,8 @@ def test_pickle(self):
280286
self.assertEqual(loaded.__args__, alias.__args__)
281287
self.assertEqual(loaded.__parameters__, alias.__parameters__)
282288

289+
# TODO: RUSTPYTHON
290+
@unittest.expectedFailure
283291
def test_copy(self):
284292
class X(list):
285293
def __copy__(self):
@@ -303,6 +311,8 @@ def test_union(self):
303311
self.assertEqual(a.__args__, (list[int], list[str]))
304312
self.assertEqual(a.__parameters__, ())
305313

314+
# TODO: RUSTPYTHON
315+
@unittest.expectedFailure
306316
def test_union_generic(self):
307317
a = typing.Union[list[T], tuple[T, ...]]
308318
self.assertEqual(a.__args__, (list[T], tuple[T, ...]))

‎Lib/test/test_types.py

Copy file name to clipboardExpand all lines: Lib/test/test_types.py
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ def test_instancecheck_and_subclasscheck(self):
742742
self.assertTrue(issubclass(dict, x))
743743
self.assertFalse(issubclass(list, x))
744744

745+
# TODO: RUSTPYTHON
746+
@unittest.expectedFailure
745747
def test_instancecheck_and_subclasscheck_order(self):
746748
T = typing.TypeVar('T')
747749

@@ -788,13 +790,17 @@ def __subclasscheck__(cls, sub):
788790
self.assertTrue(issubclass(int, x))
789791
self.assertRaises(ZeroDivisionError, issubclass, list, x)
790792

793+
# TODO: RUSTPYTHON
794+
@unittest.expectedFailure
791795
def test_or_type_operator_with_TypeVar(self):
792796
TV = typing.TypeVar('T')
793797
assert TV | str == typing.Union[TV, str]
794798
assert str | TV == typing.Union[str, TV]
795799
self.assertIs((int | TV)[int], int)
796800
self.assertIs((TV | int)[int], int)
797801

802+
# TODO: RUSTPYTHON
803+
@unittest.expectedFailure
798804
def test_union_args(self):
799805
def check(arg, expected):
800806
clear_typing_caches()
@@ -825,6 +831,8 @@ def check(arg, expected):
825831
check(x | None, (x, type(None)))
826832
check(None | x, (type(None), x))
827833

834+
# TODO: RUSTPYTHON
835+
@unittest.expectedFailure
828836
def test_union_parameter_chaining(self):
829837
T = typing.TypeVar("T")
830838
S = typing.TypeVar("S")
@@ -869,6 +877,8 @@ def eq(actual, expected, typed=True):
869877
eq(x[NT], int | NT | bytes)
870878
eq(x[S], int | S | bytes)
871879

880+
# TODO: RUSTPYTHON
881+
@unittest.expectedFailure
872882
def test_union_pickle(self):
873883
orig = list[T] | int
874884
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
@@ -878,19 +888,25 @@ def test_union_pickle(self):
878888
self.assertEqual(loaded.__args__, orig.__args__)
879889
self.assertEqual(loaded.__parameters__, orig.__parameters__)
880890

891+
# TODO: RUSTPYTHON
892+
@unittest.expectedFailure
881893
def test_union_copy(self):
882894
orig = list[T] | int
883895
for copied in (copy.copy(orig), copy.deepcopy(orig)):
884896
self.assertEqual(copied, orig)
885897
self.assertEqual(copied.__args__, orig.__args__)
886898
self.assertEqual(copied.__parameters__, orig.__parameters__)
887899

900+
# TODO: RUSTPYTHON
901+
@unittest.expectedFailure
888902
def test_union_parameter_substitution_errors(self):
889903
T = typing.TypeVar("T")
890904
x = int | T
891905
with self.assertRaises(TypeError):
892906
x[int, str]
893907

908+
# TODO: RUSTPYTHON
909+
@unittest.expectedFailure
894910
def test_or_type_operator_with_forward(self):
895911
T = typing.TypeVar('T')
896912
ForwardAfter = T | 'Forward'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.