Skip to content

Commit 30b16c1

Browse files
authored
Drop Python 3.8 branches (#13776)
1 parent 1e43190 commit 30b16c1

File tree

117 files changed

+978
-2594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+978
-2594
lines changed

stdlib/@tests/test_cases/check_importlib.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from types import ModuleType
1111
from typing_extensions import Self
1212

13+
1314
# Assert that some Path classes are Traversable.
14-
if sys.version_info >= (3, 9):
15+
def traverse(t: importlib.abc.Traversable) -> None:
16+
pass
1517

16-
def traverse(t: importlib.abc.Traversable) -> None:
17-
pass
1818

19-
traverse(pathlib.Path())
20-
traverse(zipfile.Path(""))
19+
traverse(pathlib.Path())
20+
traverse(zipfile.Path(""))
2121

2222

2323
class MetaFinder:

stdlib/@tests/test_cases/check_platform.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
from __future__ import annotations
22

33
import platform
4-
import sys
54
from typing_extensions import assert_type
65

76
# platform.uname_result emulates a 6 field named tuple, but on 3.9+ the processor
87
# field is lazily evaluated, which results in it being a little funky.
98
uname = platform.uname()
10-
if sys.version_info >= (3, 9):
11-
myuname = platform.uname_result("Darwin", "local", "22.5.0", "Darwin Kernel Version 22.5.0", "arm64")
12-
else:
13-
myuname = platform.uname_result("Darwin", "local", "22.5.0", "Darwin Kernel Version 22.5.0", "arm64", "arm")
9+
myuname = platform.uname_result("Darwin", "local", "22.5.0", "Darwin Kernel Version 22.5.0", "arm64")
1410

1511
assert_type(uname, platform.uname_result)
1612
assert_type(myuname, platform.uname_result)

stdlib/@tests/test_cases/check_xml.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import sys
43
from typing_extensions import assert_type
54
from xml.dom.minidom import Document
65

@@ -10,10 +9,9 @@
109
assert_type(document.toxml(encoding=None), str)
1110
assert_type(document.toxml(encoding="UTF8"), bytes)
1211
assert_type(document.toxml("UTF8"), bytes)
13-
if sys.version_info >= (3, 9):
14-
assert_type(document.toxml(standalone=True), str)
15-
assert_type(document.toxml("UTF8", True), bytes)
16-
assert_type(document.toxml(encoding="UTF8", standalone=True), bytes)
12+
assert_type(document.toxml(standalone=True), str)
13+
assert_type(document.toxml("UTF8", True), bytes)
14+
assert_type(document.toxml(encoding="UTF8", standalone=True), bytes)
1715

1816

1917
# Because toprettyxml can mix positional and keyword variants of the "encoding" argument, which
@@ -23,13 +21,11 @@
2321
assert_type(document.toprettyxml(), str)
2422
assert_type(document.toprettyxml(encoding=None), str)
2523
assert_type(document.toprettyxml(encoding="UTF8"), bytes)
26-
if sys.version_info >= (3, 9):
27-
assert_type(document.toprettyxml(standalone=True), str)
28-
assert_type(document.toprettyxml(encoding="UTF8", standalone=True), bytes)
24+
assert_type(document.toprettyxml(standalone=True), str)
25+
assert_type(document.toprettyxml(encoding="UTF8", standalone=True), bytes)
2926
# Test cases unique to toprettyxml
3027
assert_type(document.toprettyxml(" "), str)
3128
assert_type(document.toprettyxml(" ", "\r\n"), str)
3229
assert_type(document.toprettyxml(" ", "\r\n", "UTF8"), bytes)
33-
if sys.version_info >= (3, 9):
34-
assert_type(document.toprettyxml(" ", "\r\n", "UTF8", True), bytes)
35-
assert_type(document.toprettyxml(" ", "\r\n", standalone=True), str)
30+
assert_type(document.toprettyxml(" ", "\r\n", "UTF8", True), bytes)
31+
assert_type(document.toprettyxml(" ", "\r\n", standalone=True), str)

stdlib/@tests/test_cases/collections/check_defaultdict-py39.py

-72
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""
2+
Tests for `defaultdict.__or__` and `defaultdict.__ror__`.
3+
"""
4+
5+
from __future__ import annotations
6+
7+
import os
8+
from collections import defaultdict
9+
from typing import Mapping, TypeVar, Union
10+
from typing_extensions import Self, assert_type
11+
12+
_KT = TypeVar("_KT")
13+
_VT = TypeVar("_VT")
14+
15+
16+
class CustomDefaultDictSubclass(defaultdict[_KT, _VT]):
17+
pass
18+
19+
20+
class CustomMappingWithDunderOr(Mapping[_KT, _VT]):
21+
def __or__(self, other: Mapping[_KT, _VT]) -> dict[_KT, _VT]:
22+
return {}
23+
24+
def __ror__(self, other: Mapping[_KT, _VT]) -> dict[_KT, _VT]:
25+
return {}
26+
27+
def __ior__(self, other: Mapping[_KT, _VT]) -> Self:
28+
return self
29+
30+
31+
def test_defaultdict_dot_or(
32+
a: defaultdict[int, int],
33+
b: CustomDefaultDictSubclass[int, int],
34+
c: defaultdict[str, str],
35+
d: Mapping[int, int],
36+
e: CustomMappingWithDunderOr[str, str],
37+
) -> None:
38+
assert_type(a | b, defaultdict[int, int])
39+
40+
# In contrast to `dict.__or__`, `defaultdict.__or__` returns `Self` if called on a subclass of `defaultdict`:
41+
assert_type(b | a, CustomDefaultDictSubclass[int, int])
42+
43+
assert_type(a | c, defaultdict[Union[int, str], Union[int, str]])
44+
45+
# arbitrary mappings are not accepted by `defaultdict.__or__`;
46+
# it has to be a subclass of `dict`
47+
a | d # type: ignore
48+
49+
# but Mappings such as `os._Environ` or `CustomMappingWithDunderOr`,
50+
# which define `__ror__` methods that accept `dict`, are fine
51+
# (`os._Environ.__(r)or__` always returns `dict`, even if a `defaultdict` is passed):
52+
assert_type(a | os.environ, dict[Union[str, int], Union[str, int]])
53+
assert_type(os.environ | a, dict[Union[str, int], Union[str, int]])
54+
55+
assert_type(c | os.environ, dict[str, str])
56+
assert_type(c | e, dict[str, str])
57+
58+
assert_type(os.environ | c, dict[str, str])
59+
assert_type(e | c, dict[str, str])
60+
61+
# store "untainted" `CustomMappingWithDunderOr[str, str]` to test `__ior__` against ` defaultdict[str, str]` later
62+
# Invalid `e |= a` causes pyright to join `Unknown` to `e`'s type
63+
f = e
64+
65+
e |= c
66+
e |= a # type: ignore
67+
68+
c |= f
69+
70+
c |= a # type: ignore

stdlib/_ctypes.pyi

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
44
from abc import abstractmethod
55
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
66
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
7+
from types import GenericAlias
78
from typing import Any, ClassVar, Generic, TypeVar, final, overload, type_check_only
89
from typing_extensions import Self, TypeAlias
910

10-
if sys.version_info >= (3, 9):
11-
from types import GenericAlias
12-
1311
_T = TypeVar("_T")
1412
_CT = TypeVar("_CT", bound=_CData)
1513

@@ -317,8 +315,7 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
317315
# Can't inherit from Sized because the metaclass conflict between
318316
# Sized and _CData prevents using _CDataMeta.
319317
def __len__(self) -> int: ...
320-
if sys.version_info >= (3, 9):
321-
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
318+
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
322319

323320
def addressof(obj: _CData | _CDataType, /) -> int: ...
324321
def alignment(obj_or_type: _CData | _CDataType | type[_CData | _CDataType], /) -> int: ...

stdlib/_curses.pyi

+4-10
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,8 @@ def erasechar() -> bytes: ...
292292
def filter() -> None: ...
293293
def flash() -> None: ...
294294
def flushinp() -> None: ...
295-
296-
if sys.version_info >= (3, 9):
297-
def get_escdelay() -> int: ...
298-
def get_tabsize() -> int: ...
299-
295+
def get_escdelay() -> int: ...
296+
def get_tabsize() -> int: ...
300297
def getmouse() -> tuple[int, int, int, int, int]: ...
301298
def getsyx() -> tuple[int, int]: ...
302299
def getwin(file: SupportsRead[bytes], /) -> window: ...
@@ -341,11 +338,8 @@ def resetty() -> None: ...
341338
def resize_term(nlines: int, ncols: int, /) -> None: ...
342339
def resizeterm(nlines: int, ncols: int, /) -> None: ...
343340
def savetty() -> None: ...
344-
345-
if sys.version_info >= (3, 9):
346-
def set_escdelay(ms: int, /) -> None: ...
347-
def set_tabsize(size: int, /) -> None: ...
348-
341+
def set_escdelay(ms: int, /) -> None: ...
342+
def set_tabsize(size: int, /) -> None: ...
349343
def setsyx(y: int, x: int, /) -> None: ...
350344
def setupterm(term: str | None = None, fd: int = -1) -> None: ...
351345
def start_color() -> None: ...

stdlib/_hashlib.pyi

+34-45
Original file line numberDiff line numberDiff line change
@@ -37,53 +37,42 @@ class HASH:
3737
if sys.version_info >= (3, 10):
3838
class UnsupportedDigestmodError(ValueError): ...
3939

40-
if sys.version_info >= (3, 9):
41-
class HASHXOF(HASH):
42-
def digest(self, length: int) -> bytes: ... # type: ignore[override]
43-
def hexdigest(self, length: int) -> str: ... # type: ignore[override]
40+
class HASHXOF(HASH):
41+
def digest(self, length: int) -> bytes: ... # type: ignore[override]
42+
def hexdigest(self, length: int) -> str: ... # type: ignore[override]
4443

45-
@final
46-
class HMAC:
47-
@property
48-
def digest_size(self) -> int: ...
49-
@property
50-
def block_size(self) -> int: ...
51-
@property
52-
def name(self) -> str: ...
53-
def copy(self) -> Self: ...
54-
def digest(self) -> bytes: ...
55-
def hexdigest(self) -> str: ...
56-
def update(self, msg: ReadableBuffer) -> None: ...
57-
58-
@overload
59-
def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
60-
@overload
61-
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
62-
def get_fips_mode() -> int: ...
63-
def hmac_new(key: bytes | bytearray, msg: ReadableBuffer = b"", digestmod: _DigestMod = None) -> HMAC: ...
64-
def new(name: str, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
65-
def openssl_md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
66-
def openssl_sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
67-
def openssl_sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
68-
def openssl_sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
69-
def openssl_sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
70-
def openssl_sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
71-
def openssl_sha3_224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
72-
def openssl_sha3_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
73-
def openssl_sha3_384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
74-
def openssl_sha3_512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
75-
def openssl_shake_128(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
76-
def openssl_shake_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
77-
78-
else:
79-
def new(name: str, string: ReadableBuffer = b"") -> HASH: ...
80-
def openssl_md5(string: ReadableBuffer = b"") -> HASH: ...
81-
def openssl_sha1(string: ReadableBuffer = b"") -> HASH: ...
82-
def openssl_sha224(string: ReadableBuffer = b"") -> HASH: ...
83-
def openssl_sha256(string: ReadableBuffer = b"") -> HASH: ...
84-
def openssl_sha384(string: ReadableBuffer = b"") -> HASH: ...
85-
def openssl_sha512(string: ReadableBuffer = b"") -> HASH: ...
44+
@final
45+
class HMAC:
46+
@property
47+
def digest_size(self) -> int: ...
48+
@property
49+
def block_size(self) -> int: ...
50+
@property
51+
def name(self) -> str: ...
52+
def copy(self) -> Self: ...
53+
def digest(self) -> bytes: ...
54+
def hexdigest(self) -> str: ...
55+
def update(self, msg: ReadableBuffer) -> None: ...
8656

57+
@overload
58+
def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
59+
@overload
60+
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
61+
def get_fips_mode() -> int: ...
62+
def hmac_new(key: bytes | bytearray, msg: ReadableBuffer = b"", digestmod: _DigestMod = None) -> HMAC: ...
63+
def new(name: str, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
64+
def openssl_md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
65+
def openssl_sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
66+
def openssl_sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
67+
def openssl_sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
68+
def openssl_sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
69+
def openssl_sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
70+
def openssl_sha3_224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
71+
def openssl_sha3_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
72+
def openssl_sha3_384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
73+
def openssl_sha3_512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
74+
def openssl_shake_128(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
75+
def openssl_shake_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
8776
def hmac_digest(key: bytes | bytearray, msg: ReadableBuffer, digest: str) -> bytes: ...
8877
def pbkdf2_hmac(
8978
hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: int | None = None

stdlib/_queue.pyi

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import sys
1+
from types import GenericAlias
22
from typing import Any, Generic, TypeVar
33

4-
if sys.version_info >= (3, 9):
5-
from types import GenericAlias
6-
74
_T = TypeVar("_T")
85

96
class Empty(Exception): ...
@@ -16,5 +13,4 @@ class SimpleQueue(Generic[_T]):
1613
def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ...
1714
def put_nowait(self, item: _T) -> None: ...
1815
def qsize(self) -> int: ...
19-
if sys.version_info >= (3, 9):
20-
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
16+
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

0 commit comments

Comments
 (0)