Skip to content

Commit 9bb8c4f

Browse files
authored
[stdlib] Add missing Final (#14613)
1 parent 9b5b3ec commit 9bb8c4f

30 files changed

+197
-187
lines changed

stdlib/asyncio/tasks.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from _asyncio import (
88
_unregister_task as _unregister_task,
99
)
1010
from collections.abc import AsyncIterator, Awaitable, Coroutine, Generator, Iterable, Iterator
11-
from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
11+
from typing import Any, Final, Literal, Protocol, TypeVar, overload, type_check_only
1212
from typing_extensions import TypeAlias
1313

1414
from . import _CoroutineLike
@@ -82,9 +82,9 @@ else:
8282

8383
_TaskYieldType: TypeAlias = Future[object] | None
8484

85-
FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED
86-
FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
87-
ALL_COMPLETED = concurrent.futures.ALL_COMPLETED
85+
FIRST_COMPLETED: Final = concurrent.futures.FIRST_COMPLETED
86+
FIRST_EXCEPTION: Final = concurrent.futures.FIRST_EXCEPTION
87+
ALL_COMPLETED: Final = concurrent.futures.ALL_COMPLETED
8888

8989
if sys.version_info >= (3, 13):
9090
@type_check_only

stdlib/asyncio/windows_utils.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ if sys.platform == "win32":
99
__all__ = ("pipe", "Popen", "PIPE", "PipeHandle")
1010

1111
BUFSIZE: Final = 8192
12-
PIPE = subprocess.PIPE
13-
STDOUT = subprocess.STDOUT
12+
PIPE: Final = subprocess.PIPE
13+
STDOUT: Final = subprocess.STDOUT
1414
def pipe(*, duplex: bool = False, overlapped: tuple[bool, bool] = (True, True), bufsize: int = 8192) -> tuple[int, int]: ...
1515

1616
class PipeHandle:

stdlib/concurrent/futures/_base.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ RUNNING: Final = "RUNNING"
1515
CANCELLED: Final = "CANCELLED"
1616
CANCELLED_AND_NOTIFIED: Final = "CANCELLED_AND_NOTIFIED"
1717
FINISHED: Final = "FINISHED"
18-
_FUTURE_STATES: list[str]
19-
_STATE_TO_DESCRIPTION_MAP: dict[str, str]
18+
_STATE_TO_DESCRIPTION_MAP: Final[dict[str, str]]
2019
LOGGER: Logger
2120

2221
class Error(Exception): ...

stdlib/concurrent/futures/process.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from multiprocessing.context import BaseContext, Process
55
from multiprocessing.queues import Queue, SimpleQueue
66
from threading import Lock, Semaphore, Thread
77
from types import TracebackType
8-
from typing import Any, Generic, TypeVar, overload
8+
from typing import Any, Final, Generic, TypeVar, overload
99
from typing_extensions import TypeVarTuple, Unpack
1010
from weakref import ref
1111

@@ -28,9 +28,9 @@ class _ThreadWakeup:
2828

2929
def _python_exit() -> None: ...
3030

31-
EXTRA_QUEUED_CALLS: int
31+
EXTRA_QUEUED_CALLS: Final = 1
3232

33-
_MAX_WINDOWS_WORKERS: int
33+
_MAX_WINDOWS_WORKERS: Final = 61
3434

3535
class _RemoteTraceback(Exception):
3636
tb: str

stdlib/ctypes/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ from _ctypes import (
2626
from _typeshed import StrPath
2727
from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure
2828
from types import GenericAlias
29-
from typing import Any, ClassVar, Generic, Literal, TypeVar, overload, type_check_only
29+
from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, overload, type_check_only
3030
from typing_extensions import Self, TypeAlias, deprecated
3131

3232
if sys.platform == "win32":
@@ -55,7 +55,7 @@ if sys.version_info >= (3, 14):
5555
else:
5656
from _ctypes import POINTER as POINTER, pointer as pointer
5757

58-
DEFAULT_MODE: int
58+
DEFAULT_MODE: Final[int]
5959

6060
class ArgumentError(Exception): ...
6161

stdlib/ctypes/wintypes.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ from ctypes import (
2121
c_wchar,
2222
c_wchar_p,
2323
)
24-
from typing import Any, TypeVar
24+
from typing import Any, Final, TypeVar
2525
from typing_extensions import Self, TypeAlias
2626

2727
if sys.version_info >= (3, 12):
@@ -177,7 +177,7 @@ class MSG(Structure):
177177
pt: _CField[POINT, POINT, POINT]
178178

179179
tagMSG = MSG
180-
MAX_PATH: int
180+
MAX_PATH: Final = 260
181181

182182
class WIN32_FIND_DATAA(Structure):
183183
dwFileAttributes: _CIntLikeField[DWORD]

stdlib/curses/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ _T = TypeVar("_T")
1414
_P = ParamSpec("_P")
1515

1616
# available after calling `curses.initscr()`
17-
LINES: int
18-
COLS: int
17+
LINES: Final[int]
18+
COLS: Final[int]
1919

2020
# available after calling `curses.start_color()`
21-
COLORS: int
22-
COLOR_PAIRS: int
21+
COLORS: Final[int]
22+
COLOR_PAIRS: Final[int]
2323

2424
def wrapper(func: Callable[Concatenate[window, _P], _T], /, *arg: _P.args, **kwds: _P.kwargs) -> _T: ...
2525

stdlib/curses/ascii.pyi

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
from typing import TypeVar
1+
from typing import Final, TypeVar
22

33
_CharT = TypeVar("_CharT", str, int)
44

5-
NUL: int
6-
SOH: int
7-
STX: int
8-
ETX: int
9-
EOT: int
10-
ENQ: int
11-
ACK: int
12-
BEL: int
13-
BS: int
14-
TAB: int
15-
HT: int
16-
LF: int
17-
NL: int
18-
VT: int
19-
FF: int
20-
CR: int
21-
SO: int
22-
SI: int
23-
DLE: int
24-
DC1: int
25-
DC2: int
26-
DC3: int
27-
DC4: int
28-
NAK: int
29-
SYN: int
30-
ETB: int
31-
CAN: int
32-
EM: int
33-
SUB: int
34-
ESC: int
35-
FS: int
36-
GS: int
37-
RS: int
38-
US: int
39-
SP: int
40-
DEL: int
5+
NUL: Final = 0x00
6+
SOH: Final = 0x01
7+
STX: Final = 0x02
8+
ETX: Final = 0x03
9+
EOT: Final = 0x04
10+
ENQ: Final = 0x05
11+
ACK: Final = 0x06
12+
BEL: Final = 0x07
13+
BS: Final = 0x08
14+
TAB: Final = 0x09
15+
HT: Final = 0x09
16+
LF: Final = 0x0A
17+
NL: Final = 0x0A
18+
VT: Final = 0x0B
19+
FF: Final = 0x0C
20+
CR: Final = 0x0D
21+
SO: Final = 0x0E
22+
SI: Final = 0x0F
23+
DLE: Final = 0x10
24+
DC1: Final = 0x11
25+
DC2: Final = 0x12
26+
DC3: Final = 0x13
27+
DC4: Final = 0x14
28+
NAK: Final = 0x15
29+
SYN: Final = 0x16
30+
ETB: Final = 0x17
31+
CAN: Final = 0x18
32+
EM: Final = 0x19
33+
SUB: Final = 0x1A
34+
ESC: Final = 0x1B
35+
FS: Final = 0x1C
36+
GS: Final = 0x1D
37+
RS: Final = 0x1E
38+
US: Final = 0x1F
39+
SP: Final = 0x20
40+
DEL: Final = 0x7F
4141

42-
controlnames: list[int]
42+
controlnames: Final[list[int]]
4343

4444
def isalnum(c: str | int) -> bool: ...
4545
def isalpha(c: str | int) -> bool: ...

stdlib/email/_header_value_parser.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SPECIALSNL: Final[set[str]]
2525
def make_quoted_pairs(value: Any) -> str: ...
2626
def quote_string(value: Any) -> str: ...
2727

28-
rfc2047_matcher: Pattern[str]
28+
rfc2047_matcher: Final[Pattern[str]]
2929

3030
class TokenList(list[TokenList | Terminal]):
3131
token_type: str | None

stdlib/email/charset.pyi

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ from typing import ClassVar, Final, overload
44

55
__all__ = ["Charset", "add_alias", "add_charset", "add_codec"]
66

7-
QP: Final[int] # undocumented
8-
BASE64: Final[int] # undocumented
9-
SHORTEST: Final[int] # undocumented
7+
QP: Final = 1 # undocumented
8+
BASE64: Final = 2 # undocumented
9+
SHORTEST: Final = 3 # undocumented
10+
RFC2047_CHROME_LEN: Final = 7 # undocumented
11+
DEFAULT_CHARSET: Final = "us-ascii" # undocumented
12+
UNKNOWN8BIT: Final = "unknown-8bit" # undocumented
13+
EMPTYSTRING: Final = "" # undocumented
14+
CHARSETS: Final[dict[str, tuple[int | None, int | None, str | None]]]
15+
ALIASES: Final[dict[str, str]]
16+
CODEC_MAP: Final[dict[str, str | None]] # undocumented
1017

1118
class Charset:
1219
input_charset: str

0 commit comments

Comments
 (0)