Skip to content

Commit 85a787b

Browse files
authored
[stdlib] Mark constants as Final (#14577)
1 parent 554701e commit 85a787b

Some content is hidden

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

62 files changed

+1605
-1587
lines changed

stdlib/_ast.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ from ast import (
108108
unaryop as unaryop,
109109
withitem as withitem,
110110
)
111-
from typing import Literal
111+
from typing import Final
112112

113113
if sys.version_info >= (3, 12):
114114
from ast import (
@@ -137,9 +137,9 @@ if sys.version_info >= (3, 10):
137137
pattern as pattern,
138138
)
139139

140-
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
141-
PyCF_ONLY_AST: Literal[1024]
142-
PyCF_TYPE_COMMENTS: Literal[4096]
140+
PyCF_ALLOW_TOP_LEVEL_AWAIT: Final = 8192
141+
PyCF_ONLY_AST: Final = 1024
142+
PyCF_TYPE_COMMENTS: Final = 4096
143143

144144
if sys.version_info >= (3, 13):
145-
PyCF_OPTIMIZED_AST: Literal[33792]
145+
PyCF_OPTIMIZED_AST: Final = 33792

stdlib/_blake2.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from _typeshed import ReadableBuffer
2-
from typing import ClassVar, final
2+
from typing import ClassVar, Final, final
33
from typing_extensions import Self
44

5-
BLAKE2B_MAX_DIGEST_SIZE: int = 64
6-
BLAKE2B_MAX_KEY_SIZE: int = 64
7-
BLAKE2B_PERSON_SIZE: int = 16
8-
BLAKE2B_SALT_SIZE: int = 16
9-
BLAKE2S_MAX_DIGEST_SIZE: int = 32
10-
BLAKE2S_MAX_KEY_SIZE: int = 32
11-
BLAKE2S_PERSON_SIZE: int = 8
12-
BLAKE2S_SALT_SIZE: int = 8
5+
BLAKE2B_MAX_DIGEST_SIZE: Final = 64
6+
BLAKE2B_MAX_KEY_SIZE: Final = 64
7+
BLAKE2B_PERSON_SIZE: Final = 16
8+
BLAKE2B_SALT_SIZE: Final = 16
9+
BLAKE2S_MAX_DIGEST_SIZE: Final = 32
10+
BLAKE2S_MAX_KEY_SIZE: Final = 32
11+
BLAKE2S_PERSON_SIZE: Final = 8
12+
BLAKE2S_SALT_SIZE: Final = 8
1313

1414
@final
1515
class blake2b:

stdlib/_compat_pickle.pyi

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
IMPORT_MAPPING: dict[str, str]
2-
NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
3-
PYTHON2_EXCEPTIONS: tuple[str, ...]
4-
MULTIPROCESSING_EXCEPTIONS: tuple[str, ...]
5-
REVERSE_IMPORT_MAPPING: dict[str, str]
6-
REVERSE_NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
7-
PYTHON3_OSERROR_EXCEPTIONS: tuple[str, ...]
8-
PYTHON3_IMPORTERROR_EXCEPTIONS: tuple[str, ...]
1+
from typing import Final
2+
3+
IMPORT_MAPPING: Final[dict[str, str]]
4+
NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
5+
PYTHON2_EXCEPTIONS: Final[tuple[str, ...]]
6+
MULTIPROCESSING_EXCEPTIONS: Final[tuple[str, ...]]
7+
REVERSE_IMPORT_MAPPING: Final[dict[str, str]]
8+
REVERSE_NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
9+
PYTHON3_OSERROR_EXCEPTIONS: Final[tuple[str, ...]]
10+
PYTHON3_IMPORTERROR_EXCEPTIONS: Final[tuple[str, ...]]

stdlib/_ctypes.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ 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
77
from types import GenericAlias
8-
from typing import Any, ClassVar, Generic, TypeVar, final, overload, type_check_only
8+
from typing import Any, ClassVar, Final, Generic, TypeVar, final, overload, type_check_only
99
from typing_extensions import Self, TypeAlias
1010

1111
_T = TypeVar("_T")
1212
_CT = TypeVar("_CT", bound=_CData)
1313

14-
FUNCFLAG_CDECL: int
15-
FUNCFLAG_PYTHONAPI: int
16-
FUNCFLAG_USE_ERRNO: int
17-
FUNCFLAG_USE_LASTERROR: int
18-
RTLD_GLOBAL: int
19-
RTLD_LOCAL: int
14+
FUNCFLAG_CDECL: Final = 0x1
15+
FUNCFLAG_PYTHONAPI: Final = 0x4
16+
FUNCFLAG_USE_ERRNO: Final = 0x8
17+
FUNCFLAG_USE_LASTERROR: Final = 0x10
18+
RTLD_GLOBAL: Final[int]
19+
RTLD_LOCAL: Final[int]
2020

2121
if sys.version_info >= (3, 11):
22-
CTYPES_MAX_ARGCOUNT: int
22+
CTYPES_MAX_ARGCOUNT: Final[int]
2323

2424
if sys.version_info >= (3, 12):
25-
SIZEOF_TIME_T: int
25+
SIZEOF_TIME_T: Final[int]
2626

2727
if sys.platform == "win32":
2828
# Description, Source, HelpFile, HelpContext, scode
@@ -37,8 +37,8 @@ if sys.platform == "win32":
3737

3838
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...
3939

40-
FUNCFLAG_HRESULT: int
41-
FUNCFLAG_STDCALL: int
40+
FUNCFLAG_HRESULT: Final = 0x2
41+
FUNCFLAG_STDCALL: Final = 0x0
4242

4343
def FormatError(code: int = ...) -> str: ...
4444
def get_last_error() -> int: ...

0 commit comments

Comments
 (0)