Skip to content

Commit 2eb9c1b

Browse files
committed
Fix lazy imports CI
1 parent e5248b6 commit 2eb9c1b

3 files changed

Lines changed: 15 additions & 17 deletions

File tree

‎Doc/deprecations/pending-removal-in-3.18.rst‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ Pending removal in Python 3.18
1111
C implementation, has been deprecated since Python 3.13.
1212
(Contributed by Serhiy Storchaka in :gh:`89902`.)
1313

14-
* :mod:`typing`:
15-
16-
* :data:`typing.AnyStr` has been discouraged
17-
and deprecated since Python 3.16
18-
and is scheduled to be removed in Python 3.21.
19-
Use :pep:`695` syntax instead.
20-
2114
* Deprecations defined by :pep:`829`:
2215

2316
* ``import`` lines in :file:`{name}.pth` files are silently ignored.

‎Doc/deprecations/pending-removal-in-3.21.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ Pending removal in Python 3.21
3737

3838
* ``tempfile._TemporaryFileWrapper`` will be removed in Python 3.21. Use the
3939
public :class:`tempfile.TemporaryFileWrapper` instead.
40+
41+
* :mod:`typing`:
42+
43+
* :data:`typing.AnyStr` has been discouraged
44+
and deprecated since Python 3.16
45+
and is scheduled to be removed in Python 3.21.
46+
Use :pep:`695` syntax instead.

‎Lib/test/test_typing.py‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@
5050
import weakref
5151
import types
5252

53-
with warnings.catch_warnings():
54-
warnings.simplefilter("ignore", DeprecationWarning)
55-
56-
from typing import AnyStr
57-
5853
from test.support import (
5954
captured_stderr, cpython_only, requires_docstrings, import_helper, run_code,
6055
subTests, EqualToForwardRef,
@@ -494,7 +489,6 @@ def test_repr(self):
494489
self.assertEqual(repr(T), '~T')
495490
self.assertEqual(repr(KT), '~KT')
496491
self.assertEqual(repr(VT), '~VT')
497-
self.assertEqual(repr(AnyStr), '~AnyStr')
498492
T_co = TypeVar('T_co', covariant=True)
499493
self.assertEqual(repr(T_co), '+T_co')
500494
T_contra = TypeVar('T_contra', contravariant=True)
@@ -6393,13 +6387,15 @@ def on_bottom(self, a: int) -> int:
63936387
class CastTests(BaseTestCase):
63946388

63956389
def test_basics(self):
6390+
T = TypeVar("T")
6391+
63966392
self.assertEqual(cast(int, 42), 42)
63976393
self.assertEqual(cast(float, 42), 42)
63986394
self.assertIs(type(cast(float, 42)), int)
63996395
self.assertEqual(cast(Any, 42), 42)
64006396
self.assertEqual(cast(list, 42), 42)
64016397
self.assertEqual(cast(Union[str, float], 42), 42)
6402-
self.assertEqual(cast(AnyStr, 42), 42)
6398+
self.assertEqual(cast(T, 42), 42)
64036399
self.assertEqual(cast(None, 42), 42)
64046400

64056401
def test_errors(self):
@@ -6412,9 +6408,10 @@ class AssertTypeTests(BaseTestCase):
64126408

64136409
def test_basics(self):
64146410
arg = 42
6411+
T = TypeVar("T")
64156412
self.assertIs(assert_type(arg, int), arg)
64166413
self.assertIs(assert_type(arg, str | float), arg)
6417-
self.assertIs(assert_type(arg, AnyStr), arg)
6414+
self.assertIs(assert_type(arg, T), arg)
64186415
self.assertIs(assert_type(arg, None), arg)
64196416

64206417
def test_errors(self):
@@ -9642,7 +9639,7 @@ def test_no_isinstance(self):
96429639
class IOTests(BaseTestCase):
96439640

96449641
def test_io(self):
9645-
def stuff(a: IO) -> AnyStr:
9642+
def stuff(a: IO):
96469643
return a.readline()
96479644

96489645
a = stuff.__annotations__['a']
@@ -9651,7 +9648,6 @@ def stuff(a: IO) -> AnyStr:
96519648
self.assertEqual(repr(any_str), 'AnyStr')
96529649
self.assertEqual(any_str.__bound__, None)
96539650
self.assertEqual(any_str.__constraints__, (bytes, str))
9654-
self.assertEqual(any_str.__constraints__, AnyStr.__constraints__)
96559651

96569652
def test_textio(self):
96579653

@@ -11308,6 +11304,8 @@ def test_any_str_deprecated(self):
1130811304
with self.assertWarnsRegex(DeprecationWarning, r'typing\.AnyStr'):
1130911305
fresh.AnyStr
1131011306

11307+
self.assertEqual(repr(fresh.AnyStr), '~AnyStr')
11308+
1131111309

1131211310
class TypeIterationTests(BaseTestCase):
1131311311
_UNITERABLE_TYPES = (

0 commit comments

Comments
 (0)