Use Final for Constant Literals in the stdlib (#12332)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Max Muoto
2024-07-15 12:07:34 -05:00
committed by GitHub
parent 02b05d67c4
commit 0df6028dc8
41 changed files with 569 additions and 572 deletions

View File

@@ -1,7 +1,7 @@
import sys
from collections.abc import Callable, Iterable, Iterator, Mapping
from types import TracebackType
from typing import Any, Generic, Literal, TypeVar
from typing import Any, Final, Generic, TypeVar
from typing_extensions import Self
if sys.version_info >= (3, 9):
@@ -97,7 +97,7 @@ class ThreadPool(Pool):
) -> None: ...
# undocumented
INIT: Literal["INIT"]
RUN: Literal["RUN"]
CLOSE: Literal["CLOSE"]
TERMINATE: Literal["TERMINATE"]
INIT: Final = "INIT"
RUN: Final = "RUN"
CLOSE: Final = "CLOSE"
TERMINATE: Final = "TERMINATE"

View File

@@ -8,7 +8,7 @@ from copyreg import _DispatchTableType
from multiprocessing import connection
from pickle import _ReducedType
from socket import socket
from typing import Any, Literal
from typing import Any, Final
if sys.platform == "win32":
__all__ = ["send_handle", "recv_handle", "ForkingPickler", "register", "dump", "DupHandle", "duplicate", "steal_handle"]
@@ -43,10 +43,7 @@ if sys.platform == "win32":
def detach(self) -> int: ...
else:
if sys.platform == "darwin":
ACKNOWLEDGE: Literal[True]
else:
ACKNOWLEDGE: Literal[False]
ACKNOWLEDGE: Final[bool]
def recvfds(sock: socket, size: int) -> list[int]: ...
def send_handle(conn: HasFileno, handle: int, destination_pid: Unused) -> None: ...