Skip to content

Commit 30bbd86

Browse files
max-muotoAvasampre-commit-ci[bot]
authored
Final for distutils constants (#12454)
Co-authored-by: Avasam <samuel.06@hotmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 34b8c79 commit 30bbd86

File tree

9 files changed

+36
-35
lines changed

9 files changed

+36
-35
lines changed

stdlib/distutils/command/check.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, ClassVar, Literal
1+
from typing import Any, ClassVar, Final, Literal
22
from typing_extensions import TypeAlias
33

44
from ..cmd import Command
@@ -22,7 +22,7 @@ class SilentReporter(_Reporter):
2222
) -> None: ...
2323
def system_message(self, level, message, *children, **kwargs): ...
2424

25-
HAS_DOCUTILS: bool
25+
HAS_DOCUTILS: Final[bool]
2626

2727
class check(Command):
2828
description: str

stdlib/distutils/command/config.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from _typeshed import StrOrBytesPath
22
from collections.abc import Sequence
33
from re import Pattern
4-
from typing import Any, ClassVar, Literal
4+
from typing import Any, ClassVar, Final, Literal
55

66
from ..ccompiler import CCompiler
77
from ..cmd import Command
88

9-
LANG_EXT: dict[str, str]
9+
LANG_EXT: Final[dict[str, str]]
1010

1111
class config(Command):
1212
description: str

stdlib/distutils/command/install.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import sys
22
from collections.abc import Callable
3-
from typing import Any, ClassVar, Final
3+
from typing import Any, ClassVar, Final, Literal
44

55
from ..cmd import Command
66

7-
HAS_USER_SITE: bool
8-
SCHEME_KEYS: tuple[str, ...]
7+
HAS_USER_SITE: Final[bool]
8+
9+
SCHEME_KEYS: Final[tuple[Literal["purelib"], Literal["platlib"], Literal["headers"], Literal["scripts"], Literal["data"]]]
910
INSTALL_SCHEMES: Final[dict[str, dict[str, str]]]
1011

1112
if sys.version_info < (3, 10):

stdlib/distutils/command/install_lib.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from typing import Any, ClassVar
1+
from typing import Any, ClassVar, Final
22

33
from ..cmd import Command
44

5-
PYTHON_SOURCE_EXTENSION: str
5+
PYTHON_SOURCE_EXTENSION: Final = ".py"
66

77
class install_lib(Command):
88
description: str

stdlib/distutils/core.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ from collections.abc import Mapping
33
from distutils.cmd import Command as Command
44
from distutils.dist import Distribution as Distribution
55
from distutils.extension import Extension as Extension
6-
from typing import Any, Literal
6+
from typing import Any, Final, Literal
77

8-
USAGE: str
8+
USAGE: Final[str]
99

1010
def gen_usage(script_name: StrOrBytesPath) -> str: ...
1111

stdlib/distutils/cygwinccompiler.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
from distutils.unixccompiler import UnixCCompiler
22
from distutils.version import LooseVersion
33
from re import Pattern
4-
from typing import Literal
4+
from typing import Final, Literal
55

66
def get_msvcr() -> list[str] | None: ...
77

88
class CygwinCCompiler(UnixCCompiler): ...
99
class Mingw32CCompiler(CygwinCCompiler): ...
1010

11-
CONFIG_H_OK: str
12-
CONFIG_H_NOTOK: str
13-
CONFIG_H_UNCERTAIN: str
11+
CONFIG_H_OK: Final = "ok"
12+
CONFIG_H_NOTOK: Final = "not ok"
13+
CONFIG_H_UNCERTAIN: Final = "uncertain"
1414

1515
def check_config_h() -> tuple[Literal["ok", "not ok", "uncertain"], str]: ...
1616

17-
RE_VERSION: Pattern[bytes]
17+
RE_VERSION: Final[Pattern[bytes]]
1818

1919
def get_versions() -> tuple[LooseVersion | None, ...]: ...
2020
def is_cygwingcc() -> bool: ...

stdlib/distutils/fancy_getopt.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from collections.abc import Iterable, Mapping
22
from re import Pattern
3-
from typing import Any, overload
3+
from typing import Any, Final, overload
44
from typing_extensions import TypeAlias
55

66
_Option: TypeAlias = tuple[str, str | None, str]
77
_GR: TypeAlias = tuple[list[str], OptionDummy]
88

9-
longopt_pat: str
10-
longopt_re: Pattern[str]
11-
neg_alias_re: Pattern[str]
12-
longopt_xlate: dict[int, int]
9+
longopt_pat: Final = r"[a-zA-Z](?:[a-zA-Z0-9-]*)"
10+
longopt_re: Final[Pattern[str]]
11+
neg_alias_re: Final[Pattern[str]]
12+
longopt_xlate: Final[dict[int, int]]
1313

1414
class FancyGetopt:
1515
def __init__(self, option_table: list[_Option] | None = None) -> None: ...
@@ -25,7 +25,7 @@ def fancy_getopt(
2525
options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None
2626
) -> list[str] | _GR: ...
2727

28-
WS_TRANS: dict[int, str]
28+
WS_TRANS: Final[dict[int, str]]
2929

3030
def wrap_text(text: str, width: int) -> list[str]: ...
3131
def translate_longopt(opt: str) -> str: ...

stdlib/distutils/log.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import Any
1+
from typing import Any, Final
22

3-
DEBUG: int
4-
INFO: int
5-
WARN: int
6-
ERROR: int
7-
FATAL: int
3+
DEBUG: Final = 1
4+
INFO: Final = 2
5+
WARN: Final = 3
6+
ERROR: Final = 4
7+
FATAL: Final = 5
88

99
class Log:
1010
def __init__(self, threshold: int = 3) -> None: ...

stdlib/distutils/sysconfig.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import sys
22
from collections.abc import Mapping
33
from distutils.ccompiler import CCompiler
4-
from typing import Literal, overload
4+
from typing import Final, Literal, overload
55
from typing_extensions import deprecated
66

7-
PREFIX: str
8-
EXEC_PREFIX: str
9-
BASE_PREFIX: str
10-
BASE_EXEC_PREFIX: str
11-
project_base: str
12-
python_build: bool
7+
PREFIX: Final[str]
8+
EXEC_PREFIX: Final[str]
9+
BASE_PREFIX: Final[str]
10+
BASE_EXEC_PREFIX: Final[str]
11+
project_base: Final[str]
12+
python_build: Final[bool]
1313

1414
def expand_makefile_vars(s: str, vars: Mapping[str, str]) -> str: ...
1515
@overload

0 commit comments

Comments
 (0)