Skip to content

Commit b151e23

Browse files
authored
Add defaults for params and constants in pyinstaller (#9640)
1 parent cec6162 commit b151e23

File tree

11 files changed

+120
-116
lines changed

11 files changed

+120
-116
lines changed
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing_extensions import LiteralString
1+
from typing_extensions import Final, LiteralString
22

33
from PyInstaller import compat as compat
44

55
__all__ = ("HOMEPATH", "PLATFORM", "__version__", "DEFAULT_DISTPATH", "DEFAULT_SPECPATH", "DEFAULT_WORKPATH")
6-
__version__: str
7-
HOMEPATH: str
8-
DEFAULT_SPECPATH: str
9-
DEFAULT_DISTPATH: str
10-
DEFAULT_WORKPATH: str
11-
PLATFORM: LiteralString
6+
__version__: Final[str]
7+
HOMEPATH: Final[str]
8+
DEFAULT_SPECPATH: Final[str]
9+
DEFAULT_DISTPATH: Final[str]
10+
DEFAULT_WORKPATH: Final[str]
11+
PLATFORM: Final[LiteralString]

stubs/pyinstaller/PyInstaller/__main__.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ _PyIConfig: TypeAlias = (
1111

1212
logger: logging.Logger
1313

14-
def run(pyi_args: Iterable[str] | None = ..., pyi_config: _PyIConfig | None = ...) -> None: ...
14+
def run(pyi_args: Iterable[str] | None = None, pyi_config: _PyIConfig | None = None) -> None: ...

stubs/pyinstaller/PyInstaller/building/build_main.pyi

+13-13
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ class Analysis(Target):
1313
def __init__(
1414
self,
1515
scripts: Iterable[StrPath],
16-
pathex: Incomplete | None = ...,
17-
binaries: Incomplete | None = ...,
18-
datas: Incomplete | None = ...,
19-
hiddenimports: Incomplete | None = ...,
20-
hookspath: Incomplete | None = ...,
21-
hooksconfig: dict[str, dict[str, Any]] | None = ...,
22-
excludes: Incomplete | None = ...,
23-
runtime_hooks: Incomplete | None = ...,
24-
cipher: Incomplete | None = ...,
25-
win_no_prefer_redirects: bool = ...,
26-
win_private_assemblies: bool = ...,
27-
noarchive: bool = ...,
28-
module_collection_mode: Incomplete | None = ...,
16+
pathex: Incomplete | None = None,
17+
binaries: Incomplete | None = None,
18+
datas: Incomplete | None = None,
19+
hiddenimports: Incomplete | None = None,
20+
hookspath: Incomplete | None = None,
21+
hooksconfig: dict[str, dict[str, Any]] | None = None,
22+
excludes: Incomplete | None = None,
23+
runtime_hooks: Incomplete | None = None,
24+
cipher: Incomplete | None = None,
25+
win_no_prefer_redirects: bool = False,
26+
win_private_assemblies: bool = False,
27+
noarchive: bool = False,
28+
module_collection_mode: Incomplete | None = None,
2929
) -> None: ...

stubs/pyinstaller/PyInstaller/building/datastruct.pyi

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _TOCTuple: TypeAlias = tuple[str, str | None, _TypeCode | None]
88

99
class TOC(list[_TOCTuple]):
1010
filenames: set[str]
11-
def __init__(self, initlist: Iterable[_TOCTuple] | None = ...) -> None: ...
11+
def __init__(self, initlist: Iterable[_TOCTuple] | None = None) -> None: ...
1212
def append(self, entry: _TOCTuple) -> None: ...
1313
def insert(self, pos: SupportsIndex, entry: _TOCTuple) -> None: ...
1414
def extend(self, other: Iterable[_TOCTuple]) -> None: ...
@@ -25,6 +25,10 @@ class Tree(Target, TOC):
2525
excludes: Sequence[str]
2626
typecode: _TypeCode
2727
def __init__(
28-
self, root: str | None = ..., prefix: str | None = ..., excludes: Sequence[str] | None = ..., typecode: _TypeCode = ...
28+
self,
29+
root: str | None = None,
30+
prefix: str | None = None,
31+
excludes: Sequence[str] | None = None,
32+
typecode: _TypeCode = "DATA",
2933
) -> None: ...
3034
def assemble(self) -> None: ...

stubs/pyinstaller/PyInstaller/compat.pyi

+52-52
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,81 @@ from _typeshed import FileDescriptor, GenericPath, StrOrBytesPath
33
from collections.abc import Iterable
44
from types import ModuleType
55
from typing import AnyStr, overload
6-
from typing_extensions import Literal, TypeAlias
6+
from typing_extensions import Final, Literal, TypeAlias
77

88
_OpenFile: TypeAlias = StrOrBytesPath | FileDescriptor
99

1010
strict_collect_mode: bool
11-
is_64bits: bool
12-
is_py35: Literal[True]
13-
is_py36: Literal[True]
14-
is_py37: bool
15-
is_py38: bool
16-
is_py39: bool
17-
is_py310: bool
18-
is_py311: bool
19-
is_win: bool
20-
is_win_10: bool
21-
is_win_wine: bool
22-
is_cygwin: bool
23-
is_darwin: bool
24-
is_linux: bool
25-
is_solar: bool
26-
is_aix: bool
27-
is_freebsd: bool
28-
is_openbsd: bool
29-
is_hpux: bool
30-
is_unix: bool
31-
is_musl: bool
32-
is_macos_11_compat: bool
33-
is_macos_11_native: bool
34-
is_macos_11: bool
35-
PYDYLIB_NAMES: set[str]
36-
base_prefix: str
37-
is_venv: bool
38-
is_virtualenv: bool
39-
is_conda: bool
40-
is_pure_conda: bool
41-
python_executable: str
42-
is_ms_app_store: bool
43-
BYTECODE_MAGIC: bytes
44-
EXTENSION_SUFFIXES: list[str]
45-
ALL_SUFFIXES: list[str]
11+
is_64bits: Final[bool]
12+
is_py35: Final = True
13+
is_py36: Final = True
14+
is_py37: Final[bool]
15+
is_py38: Final[bool]
16+
is_py39: Final[bool]
17+
is_py310: Final[bool]
18+
is_py311: Final[bool]
19+
is_win: Final[bool]
20+
is_win_10: Final[bool]
21+
is_win_wine: Final[bool]
22+
is_cygwin: Final[bool]
23+
is_darwin: Final[bool]
24+
is_linux: Final[bool]
25+
is_solar: Final[bool]
26+
is_aix: Final[bool]
27+
is_freebsd: Final[bool]
28+
is_openbsd: Final[bool]
29+
is_hpux: Final[bool]
30+
is_unix: Final[bool]
31+
is_musl: Final[bool]
32+
is_macos_11_compat: Final[bool]
33+
is_macos_11_native: Final[bool]
34+
is_macos_11: Final[bool]
35+
PYDYLIB_NAMES: Final[set[str]]
36+
base_prefix: Final[str]
37+
is_venv: Final[bool]
38+
is_virtualenv: Final[bool]
39+
is_conda: Final[bool]
40+
is_pure_conda: Final[bool]
41+
python_executable: Final[str]
42+
is_ms_app_store: Final[bool]
43+
BYTECODE_MAGIC: Final[bytes]
44+
EXTENSION_SUFFIXES: Final[list[str]]
45+
ALL_SUFFIXES: Final[list[str]]
4646

47-
architecture: Literal["64bit", "n32bit", "32bit"]
48-
system: Literal["Cygwin", "Linux", "Darwin", "Java", "Windows"]
49-
machine: Literal["sw_64", "loongarch64", "arm", "intel", "ppc", "mips", "riscv", "s390x", "unknown", None]
47+
architecture: Final[Literal["64bit", "n32bit", "32bit"]]
48+
system: Final[Literal["Cygwin", "Linux", "Darwin", "Java", "Windows"]]
49+
machine: Final[Literal["sw_64", "loongarch64", "arm", "intel", "ppc", "mips", "riscv", "s390x", "unknown", None]]
5050

5151
def is_wine_dll(filename: _OpenFile) -> bool: ...
5252
@overload
5353
def getenv(name: str, default: str) -> str: ...
5454
@overload
55-
def getenv(name: str, default: None = ...) -> str | None: ...
55+
def getenv(name: str, default: None = None) -> str | None: ...
5656
def setenv(name: str, value: str) -> None: ...
5757
def unsetenv(name: str) -> None: ...
5858
def exec_command(
59-
*cmdargs: str, encoding: str | None = ..., raise_enoent: bool | None = ..., **kwargs: int | bool | Iterable[int] | None
59+
*cmdargs: str, encoding: str | None = None, raise_enoent: bool | None = None, **kwargs: int | bool | Iterable[int] | None
6060
) -> str: ...
6161
def exec_command_rc(*cmdargs: str, **kwargs: float | bool | Iterable[int] | None) -> int: ...
6262
def exec_command_stdout(
63-
*command_args: str, encoding: str | None = ..., **kwargs: float | str | bytes | bool | Iterable[int] | None
63+
*command_args: str, encoding: str | None = None, **kwargs: float | str | bytes | bool | Iterable[int] | None
6464
) -> str: ...
6565
def exec_command_all(
66-
*cmdargs: str, encoding: str | None = ..., **kwargs: int | bool | Iterable[int] | None
66+
*cmdargs: str, encoding: str | None = None, **kwargs: int | bool | Iterable[int] | None
6767
) -> tuple[int, str, str]: ...
6868
def exec_python(*args: str, **kwargs: str | None) -> str: ...
6969
def exec_python_rc(*args: str, **kwargs: str | None) -> int: ...
7070
def expand_path(path: GenericPath[AnyStr]) -> AnyStr: ...
71-
def getsitepackages(prefixes: Iterable[str] | None = ...) -> list[str]: ...
71+
def getsitepackages(prefixes: Iterable[str] | None = None) -> list[str]: ...
7272
def importlib_load_source(name: str, pathname: str) -> ModuleType: ...
7373

74-
PY3_BASE_MODULES: set[str]
75-
PURE_PYTHON_MODULE_TYPES: set[str]
76-
SPECIAL_MODULE_TYPES: set[str]
77-
BINARY_MODULE_TYPES: set[str]
78-
VALID_MODULE_TYPES: set[str]
79-
BAD_MODULE_TYPES: set[str]
80-
ALL_MODULE_TYPES: set[str]
81-
MODULE_TYPES_TO_TOC_DICT: dict[str, str]
74+
PY3_BASE_MODULES: Final[set[str]]
75+
PURE_PYTHON_MODULE_TYPES: Final[set[str]]
76+
SPECIAL_MODULE_TYPES: Final[set[str]]
77+
BINARY_MODULE_TYPES: Final[set[str]]
78+
VALID_MODULE_TYPES: Final[set[str]]
79+
BAD_MODULE_TYPES: Final[set[str]]
80+
ALL_MODULE_TYPES: Final[set[str]]
81+
MODULE_TYPES_TO_TOC_DICT: Final[dict[str, str]]
8282

8383
def check_requirements() -> None: ...

stubs/pyinstaller/PyInstaller/depend/analysis.pyi

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class PyiModuleGraph: # incomplete
1919
user_hook_dirs: Iterable[StrPath] = ...,
2020
excludes: Iterable[str] = ...,
2121
*,
22-
path: Iterable[str] | None = ...,
22+
path: Iterable[str] | None = None,
2323
replace_paths: Iterable[tuple[StrPath, StrPath]] = ...,
2424
implies: SupportsKeysAndGetItem[str, _LazyNode] | Iterable[tuple[str, _LazyNode]] = ...,
25-
graph: _Graph | None = ...,
26-
debug: int = ...,
25+
graph: _Graph | None = None,
26+
debug: bool = False,
2727
) -> None: ...

stubs/pyinstaller/PyInstaller/isolated/_parent.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _R = TypeVar("_R")
99
_P = ParamSpec("_P")
1010

1111
class Python:
12-
def __init__(self, strict_mode: bool | None = ...) -> None: ...
12+
def __init__(self, strict_mode: bool | None = None) -> None: ...
1313
def __enter__(self: Self) -> Self: ...
1414
def __exit__(
1515
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None

stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Alias(str): ...
3737
class BaseModule(Node):
3838
filename: str
3939
packagepath: str
40-
def __init__(self, name: str, filename: str | None = ..., path: str | None = ...) -> None: ...
40+
def __init__(self, name: str, filename: str | None = None, path: str | None = None) -> None: ...
4141
# Returns a tuple of length 0, 1, 2, or 3
4242
def infoTuple(self) -> tuple[str, ...]: ... # type: ignore[override]
4343

stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi

+24-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import logging
44
from _typeshed import StrOrBytesPath, StrPath
55
from collections.abc import Callable, Iterable
66
from typing import Any
7-
from typing_extensions import Literal
7+
from typing_extensions import Final, Literal
88

99
import pkg_resources
1010
from PyInstaller import HOMEPATH as HOMEPATH
@@ -15,14 +15,14 @@ from PyInstaller.utils.hooks.win32 import get_pywin32_module_file_attribute as g
1515
conda_support = conda
1616

1717
logger: logging.Logger
18-
PY_IGNORE_EXTENSIONS: set[str]
18+
PY_IGNORE_EXTENSIONS: Final[set[str]]
1919
hook_variables: dict[str, str]
2020

2121
def exec_statement(statement: str) -> str | int: ...
2222
def exec_statement_rc(statement: str) -> str | int: ...
2323
def eval_statement(statement: str) -> Any | Literal[""]: ...
2424
def get_pyextension_imports(module_name: str) -> list[str]: ...
25-
def get_homebrew_path(formula: str = ...) -> str | None: ...
25+
def get_homebrew_path(formula: str = "") -> str | None: ...
2626
def remove_prefix(string: str, prefix: str) -> str: ...
2727
def remove_suffix(string: str, suffix: str) -> str: ...
2828
def remove_file_extension(filename: str) -> str: ...
@@ -31,52 +31,52 @@ def get_module_attribute(module_name: str, attr_name: str) -> Any: ...
3131
def get_module_file_attribute(package: str) -> str | None: ...
3232
def is_module_satisfies(
3333
requirements: Iterable[str] | pkg_resources.Requirement,
34-
version: str | pkg_resources.Distribution | None = ...,
35-
version_attr: str = ...,
34+
version: str | pkg_resources.Distribution | None = None,
35+
version_attr: str = "__version__",
3636
) -> bool: ...
3737
def is_package(module_name: str) -> bool: ...
3838
def get_all_package_paths(package: str) -> list[str]: ...
3939
def package_base_path(package_path: str, package: str) -> str: ...
4040
def get_package_paths(package: str) -> tuple[str, str]: ...
4141
def collect_submodules(
42-
package: str, filter: Callable[[str], bool] = ..., on_error: Literal["ignore", "warn once", "warn", "raise"] = ...
42+
package: str, filter: Callable[[str], bool] = ..., on_error: Literal["ignore", "warn once", "warn", "raise"] = "warn once"
4343
) -> list[str]: ...
4444
def is_module_or_submodule(name: str, mod_or_submod: str) -> bool: ...
4545

46-
PY_DYLIB_PATTERNS: list[str]
46+
PY_DYLIB_PATTERNS: Final[list[str]]
4747

48-
def collect_dynamic_libs(package: str, destdir: object = ...) -> list[tuple[str, str]]: ...
48+
def collect_dynamic_libs(package: str, destdir: object = None) -> list[tuple[str, str]]: ...
4949
def collect_data_files(
5050
package: str,
51-
include_py_files: bool = ...,
52-
subdir: StrPath | None = ...,
53-
excludes: Iterable[str] | None = ...,
54-
includes: Iterable[str] | None = ...,
51+
include_py_files: bool = False,
52+
subdir: StrPath | None = None,
53+
excludes: Iterable[str] | None = None,
54+
includes: Iterable[str] | None = None,
5555
) -> list[tuple[str, str]]: ...
5656
def collect_system_data_files(
57-
path: str, destdir: StrPath | None = ..., include_py_files: bool = ...
57+
path: str, destdir: StrPath | None = None, include_py_files: bool = False
5858
) -> list[tuple[str, str]]: ...
59-
def copy_metadata(package_name: str, recursive: bool = ...) -> list[tuple[str, str]]: ...
59+
def copy_metadata(package_name: str, recursive: bool = False) -> list[tuple[str, str]]: ...
6060
def get_installer(module: str) -> str | None: ...
6161
def requirements_for_package(package_name: str) -> list[str]: ...
6262
def collect_all(
6363
package_name: str,
64-
include_py_files: bool = ...,
65-
filter_submodules: Callable[[str], bool] | None = ...,
66-
exclude_datas: Iterable[str] | None = ...,
67-
include_datas: Iterable[str] | None = ...,
68-
on_error: Literal["ignore", "warn once", "warn", "raise"] = ...,
64+
include_py_files: bool = True,
65+
filter_submodules: Callable[[str], bool] | None = None,
66+
exclude_datas: Iterable[str] | None = None,
67+
include_datas: Iterable[str] | None = None,
68+
on_error: Literal["ignore", "warn once", "warn", "raise"] = "warn once",
6969
) -> tuple[list[tuple[str, str]], list[tuple[str, str]], list[str]]: ...
7070
def collect_entry_point(name: str) -> tuple[tuple[str, str], list[str]]: ...
7171
def get_hook_config(hook_api: PostGraphAPI, module_name: str, key: str) -> None: ...
7272
def include_or_exclude_file(
7373
filename: StrOrBytesPath,
74-
include_list: Iterable[StrOrBytesPath] | None = ...,
75-
exclude_list: Iterable[StrOrBytesPath] | None = ...,
74+
include_list: Iterable[StrOrBytesPath] | None = None,
75+
exclude_list: Iterable[StrOrBytesPath] | None = None,
7676
) -> bool: ...
7777
def collect_delvewheel_libs_directory(
7878
package_name: str,
79-
libdir_name: StrPath | None = ...,
80-
datas: list[tuple[str, str]] | None = ...,
81-
binaries: list[tuple[str, str]] | None = ...,
79+
libdir_name: StrPath | None = None,
80+
datas: list[tuple[str, str]] | None = None,
81+
binaries: list[tuple[str, str]] | None = None,
8282
) -> tuple[list[tuple[str, str]], list[tuple[str, str]]]: ...

stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import sys
44
from _typeshed import StrOrBytesPath
55
from collections.abc import Iterable
66
from pathlib import Path, PurePosixPath
7-
from typing_extensions import TypedDict
7+
from typing_extensions import Final, TypedDict
88

99
if sys.version_info >= (3, 8):
1010
from importlib.metadata import PackagePath as _PackagePath
1111
else:
1212
# Same as importlib_metadata.PackagePath
1313
class _PackagePath(PurePosixPath):
14-
def read_text(self, encoding: str = ...) -> str: ...
14+
def read_text(self, encoding: str = "utf-8") -> str: ...
1515
def read_binary(self) -> str: ...
1616
def locate(self) -> Path: ...
1717

18-
CONDA_ROOT: Path
19-
CONDA_META_DIR: Path
20-
PYTHONPATH_PREFIXES: list[Path]
18+
CONDA_ROOT: Final[Path]
19+
CONDA_META_DIR: Final[Path]
20+
PYTHONPATH_PREFIXES: Final[list[Path]]
2121

2222
class _RawDict(TypedDict):
2323
name: str
@@ -45,11 +45,11 @@ package_distribution = Distribution.from_package_name
4545
class PackagePath(_PackagePath):
4646
def locate(self) -> Path: ...
4747

48-
def walk_dependency_tree(initial: str, excludes: Iterable[str] | None = ...) -> dict[str, Distribution]: ...
49-
def requires(name: str, strip_versions: bool = ...) -> list[str]: ...
50-
def files(name: str, dependencies: bool = ..., excludes: Iterable[str] | None = ...) -> list[PackagePath]: ...
48+
def walk_dependency_tree(initial: str, excludes: Iterable[str] | None = None) -> dict[str, Distribution]: ...
49+
def requires(name: str, strip_versions: bool = False) -> list[str]: ...
50+
def files(name: str, dependencies: bool = False, excludes: Iterable[str] | None = None) -> list[PackagePath]: ...
5151
def collect_dynamic_libs(
52-
name: str, dest: str = ..., dependencies: bool = ..., excludes: Iterable[str] | None = ...
52+
name: str, dest: str = ".", dependencies: bool = True, excludes: Iterable[str] | None = None
5353
) -> list[tuple[str, str]]: ...
5454

5555
distributions: dict[str, Distribution]
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Referenced in: https://pyinstaller.org/en/stable/advanced-topics.html#module-pyi_splash
22
# Source: https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/fake-modules/pyi_splash.py
3-
from typing_extensions import Literal
3+
from typing_extensions import Final
44

55
__all__ = ["CLOSE_CONNECTION", "FLUSH_CHARACTER", "is_alive", "close", "update_text"]
66

77
def is_alive() -> bool: ...
88
def update_text(msg: str) -> None: ...
99
def close() -> None: ...
1010

11-
CLOSE_CONNECTION: Literal[b"\x04"]
12-
FLUSH_CHARACTER: Literal[b"\r"]
11+
CLOSE_CONNECTION: Final = b"\x04"
12+
FLUSH_CHARACTER: Final = b"\x0D"

0 commit comments

Comments
 (0)