Skip to content

[stdlib] Mark constants as Final #14577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ from ast import (
unaryop as unaryop,
withitem as withitem,
)
from typing import Literal
from typing import Final

if sys.version_info >= (3, 12):
from ast import (
Expand Down Expand Up @@ -137,9 +137,9 @@ if sys.version_info >= (3, 10):
pattern as pattern,
)

PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
PyCF_ONLY_AST: Literal[1024]
PyCF_TYPE_COMMENTS: Literal[4096]
PyCF_ALLOW_TOP_LEVEL_AWAIT: Final = 8192
PyCF_ONLY_AST: Final = 1024
PyCF_TYPE_COMMENTS: Final = 4096

if sys.version_info >= (3, 13):
PyCF_OPTIMIZED_AST: Literal[33792]
PyCF_OPTIMIZED_AST: Final = 33792
18 changes: 9 additions & 9 deletions stdlib/_blake2.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from _typeshed import ReadableBuffer
from typing import ClassVar, final
from typing import ClassVar, Final, final
from typing_extensions import Self

BLAKE2B_MAX_DIGEST_SIZE: int = 64
BLAKE2B_MAX_KEY_SIZE: int = 64
BLAKE2B_PERSON_SIZE: int = 16
BLAKE2B_SALT_SIZE: int = 16
BLAKE2S_MAX_DIGEST_SIZE: int = 32
BLAKE2S_MAX_KEY_SIZE: int = 32
BLAKE2S_PERSON_SIZE: int = 8
BLAKE2S_SALT_SIZE: int = 8
BLAKE2B_MAX_DIGEST_SIZE: Final = 64
BLAKE2B_MAX_KEY_SIZE: Final = 64
BLAKE2B_PERSON_SIZE: Final = 16
BLAKE2B_SALT_SIZE: Final = 16
BLAKE2S_MAX_DIGEST_SIZE: Final = 32
BLAKE2S_MAX_KEY_SIZE: Final = 32
BLAKE2S_PERSON_SIZE: Final = 8
BLAKE2S_SALT_SIZE: Final = 8

@final
class blake2b:
Expand Down
18 changes: 10 additions & 8 deletions stdlib/_compat_pickle.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
IMPORT_MAPPING: dict[str, str]
NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
PYTHON2_EXCEPTIONS: tuple[str, ...]
MULTIPROCESSING_EXCEPTIONS: tuple[str, ...]
REVERSE_IMPORT_MAPPING: dict[str, str]
REVERSE_NAME_MAPPING: dict[tuple[str, str], tuple[str, str]]
PYTHON3_OSERROR_EXCEPTIONS: tuple[str, ...]
PYTHON3_IMPORTERROR_EXCEPTIONS: tuple[str, ...]
from typing import Final

IMPORT_MAPPING: Final[dict[str, str]]
NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
PYTHON2_EXCEPTIONS: Final[tuple[str, ...]]
MULTIPROCESSING_EXCEPTIONS: Final[tuple[str, ...]]
REVERSE_IMPORT_MAPPING: Final[dict[str, str]]
REVERSE_NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
PYTHON3_OSERROR_EXCEPTIONS: Final[tuple[str, ...]]
PYTHON3_IMPORTERROR_EXCEPTIONS: Final[tuple[str, ...]]
22 changes: 11 additions & 11 deletions stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
from types import GenericAlias
from typing import Any, ClassVar, Generic, TypeVar, final, overload, type_check_only
from typing import Any, ClassVar, Final, Generic, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias

_T = TypeVar("_T")
_CT = TypeVar("_CT", bound=_CData)

FUNCFLAG_CDECL: int
FUNCFLAG_PYTHONAPI: int
FUNCFLAG_USE_ERRNO: int
FUNCFLAG_USE_LASTERROR: int
RTLD_GLOBAL: int
RTLD_LOCAL: int
FUNCFLAG_CDECL: Final = 0x1
FUNCFLAG_PYTHONAPI: Final = 0x4
FUNCFLAG_USE_ERRNO: Final = 0x8
FUNCFLAG_USE_LASTERROR: Final = 0x10
RTLD_GLOBAL: Final[int]
RTLD_LOCAL: Final[int]

if sys.version_info >= (3, 11):
CTYPES_MAX_ARGCOUNT: int
CTYPES_MAX_ARGCOUNT: Final[int]

if sys.version_info >= (3, 12):
SIZEOF_TIME_T: int
SIZEOF_TIME_T: Final[int]

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

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

FUNCFLAG_HRESULT: int
FUNCFLAG_STDCALL: int
FUNCFLAG_HRESULT: Final = 0x2
FUNCFLAG_STDCALL: Final = 0x0

def FormatError(code: int = ...) -> str: ...
def get_last_error() -> int: ...
Expand Down
Loading
Loading