Skip to content

Add defaults for params and constants in pyinstaller #9640

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 3 commits into from
Feb 1, 2023
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
14 changes: 7 additions & 7 deletions stubs/pyinstaller/PyInstaller/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing_extensions import LiteralString
from typing_extensions import Final, LiteralString

from PyInstaller import compat as compat

__all__ = ("HOMEPATH", "PLATFORM", "__version__", "DEFAULT_DISTPATH", "DEFAULT_SPECPATH", "DEFAULT_WORKPATH")
__version__: str
HOMEPATH: str
DEFAULT_SPECPATH: str
DEFAULT_DISTPATH: str
DEFAULT_WORKPATH: str
PLATFORM: LiteralString
__version__: Final[str]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the special meaning of __version__, I feel like it should always be considered constant/final. Maybe a project-wide search&replace for ^__version__: str$ --> __version__: Final[str] could have value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good

HOMEPATH: Final[str]
DEFAULT_SPECPATH: Final[str]
DEFAULT_DISTPATH: Final[str]
DEFAULT_WORKPATH: Final[str]
PLATFORM: Final[LiteralString]
2 changes: 1 addition & 1 deletion stubs/pyinstaller/PyInstaller/__main__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ _PyIConfig: TypeAlias = (

logger: logging.Logger

def run(pyi_args: Iterable[str] | None = ..., pyi_config: _PyIConfig | None = ...) -> None: ...
def run(pyi_args: Iterable[str] | None = None, pyi_config: _PyIConfig | None = None) -> None: ...
26 changes: 13 additions & 13 deletions stubs/pyinstaller/PyInstaller/building/build_main.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class Analysis(Target):
def __init__(
self,
scripts: Iterable[StrPath],
pathex: Incomplete | None = ...,
binaries: Incomplete | None = ...,
datas: Incomplete | None = ...,
hiddenimports: Incomplete | None = ...,
hookspath: Incomplete | None = ...,
hooksconfig: dict[str, dict[str, Any]] | None = ...,
excludes: Incomplete | None = ...,
runtime_hooks: Incomplete | None = ...,
cipher: Incomplete | None = ...,
win_no_prefer_redirects: bool = ...,
win_private_assemblies: bool = ...,
noarchive: bool = ...,
module_collection_mode: Incomplete | None = ...,
pathex: Incomplete | None = None,
binaries: Incomplete | None = None,
datas: Incomplete | None = None,
hiddenimports: Incomplete | None = None,
hookspath: Incomplete | None = None,
hooksconfig: dict[str, dict[str, Any]] | None = None,
excludes: Incomplete | None = None,
runtime_hooks: Incomplete | None = None,
cipher: Incomplete | None = None,
win_no_prefer_redirects: bool = False,
win_private_assemblies: bool = False,
noarchive: bool = False,
module_collection_mode: Incomplete | None = None,
) -> None: ...
8 changes: 6 additions & 2 deletions stubs/pyinstaller/PyInstaller/building/datastruct.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _TOCTuple: TypeAlias = tuple[str, str | None, _TypeCode | None]

class TOC(list[_TOCTuple]):
filenames: set[str]
def __init__(self, initlist: Iterable[_TOCTuple] | None = ...) -> None: ...
def __init__(self, initlist: Iterable[_TOCTuple] | None = None) -> None: ...
def append(self, entry: _TOCTuple) -> None: ...
def insert(self, pos: SupportsIndex, entry: _TOCTuple) -> None: ...
def extend(self, other: Iterable[_TOCTuple]) -> None: ...
Expand All @@ -25,6 +25,10 @@ class Tree(Target, TOC):
excludes: Sequence[str]
typecode: _TypeCode
def __init__(
self, root: str | None = ..., prefix: str | None = ..., excludes: Sequence[str] | None = ..., typecode: _TypeCode = ...
self,
root: str | None = None,
prefix: str | None = None,
excludes: Sequence[str] | None = None,
typecode: _TypeCode = "DATA",
) -> None: ...
def assemble(self) -> None: ...
104 changes: 52 additions & 52 deletions stubs/pyinstaller/PyInstaller/compat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,81 @@ from _typeshed import FileDescriptor, GenericPath, StrOrBytesPath
from collections.abc import Iterable
from types import ModuleType
from typing import AnyStr, overload
from typing_extensions import Literal, TypeAlias
from typing_extensions import Final, Literal, TypeAlias

_OpenFile: TypeAlias = StrOrBytesPath | FileDescriptor

strict_collect_mode: bool
is_64bits: bool
is_py35: Literal[True]
is_py36: Literal[True]
is_py37: bool
is_py38: bool
is_py39: bool
is_py310: bool
is_py311: bool
is_win: bool
is_win_10: bool
is_win_wine: bool
is_cygwin: bool
is_darwin: bool
is_linux: bool
is_solar: bool
is_aix: bool
is_freebsd: bool
is_openbsd: bool
is_hpux: bool
is_unix: bool
is_musl: bool
is_macos_11_compat: bool
is_macos_11_native: bool
is_macos_11: bool
PYDYLIB_NAMES: set[str]
base_prefix: str
is_venv: bool
is_virtualenv: bool
is_conda: bool
is_pure_conda: bool
python_executable: str
is_ms_app_store: bool
BYTECODE_MAGIC: bytes
EXTENSION_SUFFIXES: list[str]
ALL_SUFFIXES: list[str]
is_64bits: Final[bool]
is_py35: Final = True
is_py36: Final = True
is_py37: Final[bool]
is_py38: Final[bool]
is_py39: Final[bool]
is_py310: Final[bool]
is_py311: Final[bool]
is_win: Final[bool]
is_win_10: Final[bool]
is_win_wine: Final[bool]
is_cygwin: Final[bool]
is_darwin: Final[bool]
is_linux: Final[bool]
is_solar: Final[bool]
is_aix: Final[bool]
is_freebsd: Final[bool]
is_openbsd: Final[bool]
is_hpux: Final[bool]
is_unix: Final[bool]
is_musl: Final[bool]
is_macos_11_compat: Final[bool]
is_macos_11_native: Final[bool]
is_macos_11: Final[bool]
PYDYLIB_NAMES: Final[set[str]]
base_prefix: Final[str]
is_venv: Final[bool]
is_virtualenv: Final[bool]
is_conda: Final[bool]
is_pure_conda: Final[bool]
python_executable: Final[str]
is_ms_app_store: Final[bool]
BYTECODE_MAGIC: Final[bytes]
EXTENSION_SUFFIXES: Final[list[str]]
ALL_SUFFIXES: Final[list[str]]

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

def is_wine_dll(filename: _OpenFile) -> bool: ...
@overload
def getenv(name: str, default: str) -> str: ...
@overload
def getenv(name: str, default: None = ...) -> str | None: ...
def getenv(name: str, default: None = None) -> str | None: ...
def setenv(name: str, value: str) -> None: ...
def unsetenv(name: str) -> None: ...
def exec_command(
*cmdargs: str, encoding: str | None = ..., raise_enoent: bool | None = ..., **kwargs: int | bool | Iterable[int] | None
*cmdargs: str, encoding: str | None = None, raise_enoent: bool | None = None, **kwargs: int | bool | Iterable[int] | None
) -> str: ...
def exec_command_rc(*cmdargs: str, **kwargs: float | bool | Iterable[int] | None) -> int: ...
def exec_command_stdout(
*command_args: str, encoding: str | None = ..., **kwargs: float | str | bytes | bool | Iterable[int] | None
*command_args: str, encoding: str | None = None, **kwargs: float | str | bytes | bool | Iterable[int] | None
) -> str: ...
def exec_command_all(
*cmdargs: str, encoding: str | None = ..., **kwargs: int | bool | Iterable[int] | None
*cmdargs: str, encoding: str | None = None, **kwargs: int | bool | Iterable[int] | None
) -> tuple[int, str, str]: ...
def exec_python(*args: str, **kwargs: str | None) -> str: ...
def exec_python_rc(*args: str, **kwargs: str | None) -> int: ...
def expand_path(path: GenericPath[AnyStr]) -> AnyStr: ...
def getsitepackages(prefixes: Iterable[str] | None = ...) -> list[str]: ...
def getsitepackages(prefixes: Iterable[str] | None = None) -> list[str]: ...
def importlib_load_source(name: str, pathname: str) -> ModuleType: ...

PY3_BASE_MODULES: set[str]
PURE_PYTHON_MODULE_TYPES: set[str]
SPECIAL_MODULE_TYPES: set[str]
BINARY_MODULE_TYPES: set[str]
VALID_MODULE_TYPES: set[str]
BAD_MODULE_TYPES: set[str]
ALL_MODULE_TYPES: set[str]
MODULE_TYPES_TO_TOC_DICT: dict[str, str]
PY3_BASE_MODULES: Final[set[str]]
PURE_PYTHON_MODULE_TYPES: Final[set[str]]
SPECIAL_MODULE_TYPES: Final[set[str]]
BINARY_MODULE_TYPES: Final[set[str]]
VALID_MODULE_TYPES: Final[set[str]]
BAD_MODULE_TYPES: Final[set[str]]
ALL_MODULE_TYPES: Final[set[str]]
MODULE_TYPES_TO_TOC_DICT: Final[dict[str, str]]

def check_requirements() -> None: ...
6 changes: 3 additions & 3 deletions stubs/pyinstaller/PyInstaller/depend/analysis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class PyiModuleGraph: # incomplete
user_hook_dirs: Iterable[StrPath] = ...,
excludes: Iterable[str] = ...,
*,
path: Iterable[str] | None = ...,
path: Iterable[str] | None = None,
replace_paths: Iterable[tuple[StrPath, StrPath]] = ...,
implies: SupportsKeysAndGetItem[str, _LazyNode] | Iterable[tuple[str, _LazyNode]] = ...,
graph: _Graph | None = ...,
debug: int = ...,
graph: _Graph | None = None,
debug: bool = False,
) -> None: ...
2 changes: 1 addition & 1 deletion stubs/pyinstaller/PyInstaller/isolated/_parent.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _R = TypeVar("_R")
_P = ParamSpec("_P")

class Python:
def __init__(self, strict_mode: bool | None = ...) -> None: ...
def __init__(self, strict_mode: bool | None = None) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Alias(str): ...
class BaseModule(Node):
filename: str
packagepath: str
def __init__(self, name: str, filename: str | None = ..., path: str | None = ...) -> None: ...
def __init__(self, name: str, filename: str | None = None, path: str | None = None) -> None: ...
# Returns a tuple of length 0, 1, 2, or 3
def infoTuple(self) -> tuple[str, ...]: ... # type: ignore[override]

Expand Down
48 changes: 24 additions & 24 deletions stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import logging
from _typeshed import StrOrBytesPath, StrPath
from collections.abc import Callable, Iterable
from typing import Any
from typing_extensions import Literal
from typing_extensions import Final, Literal

import pkg_resources
from PyInstaller import HOMEPATH as HOMEPATH
Expand All @@ -15,14 +15,14 @@ from PyInstaller.utils.hooks.win32 import get_pywin32_module_file_attribute as g
conda_support = conda

logger: logging.Logger
PY_IGNORE_EXTENSIONS: set[str]
PY_IGNORE_EXTENSIONS: Final[set[str]]
hook_variables: dict[str, str]

def exec_statement(statement: str) -> str | int: ...
def exec_statement_rc(statement: str) -> str | int: ...
def eval_statement(statement: str) -> Any | Literal[""]: ...
def get_pyextension_imports(module_name: str) -> list[str]: ...
def get_homebrew_path(formula: str = ...) -> str | None: ...
def get_homebrew_path(formula: str = "") -> str | None: ...
def remove_prefix(string: str, prefix: str) -> str: ...
def remove_suffix(string: str, suffix: str) -> str: ...
def remove_file_extension(filename: str) -> str: ...
Expand All @@ -31,52 +31,52 @@ def get_module_attribute(module_name: str, attr_name: str) -> Any: ...
def get_module_file_attribute(package: str) -> str | None: ...
def is_module_satisfies(
requirements: Iterable[str] | pkg_resources.Requirement,
version: str | pkg_resources.Distribution | None = ...,
version_attr: str = ...,
version: str | pkg_resources.Distribution | None = None,
version_attr: str = "__version__",
) -> bool: ...
def is_package(module_name: str) -> bool: ...
def get_all_package_paths(package: str) -> list[str]: ...
def package_base_path(package_path: str, package: str) -> str: ...
def get_package_paths(package: str) -> tuple[str, str]: ...
def collect_submodules(
package: str, filter: Callable[[str], bool] = ..., on_error: Literal["ignore", "warn once", "warn", "raise"] = ...
package: str, filter: Callable[[str], bool] = ..., on_error: Literal["ignore", "warn once", "warn", "raise"] = "warn once"
) -> list[str]: ...
def is_module_or_submodule(name: str, mod_or_submod: str) -> bool: ...

PY_DYLIB_PATTERNS: list[str]
PY_DYLIB_PATTERNS: Final[list[str]]

def collect_dynamic_libs(package: str, destdir: object = ...) -> list[tuple[str, str]]: ...
def collect_dynamic_libs(package: str, destdir: object = None) -> list[tuple[str, str]]: ...
def collect_data_files(
package: str,
include_py_files: bool = ...,
subdir: StrPath | None = ...,
excludes: Iterable[str] | None = ...,
includes: Iterable[str] | None = ...,
include_py_files: bool = False,
subdir: StrPath | None = None,
excludes: Iterable[str] | None = None,
includes: Iterable[str] | None = None,
) -> list[tuple[str, str]]: ...
def collect_system_data_files(
path: str, destdir: StrPath | None = ..., include_py_files: bool = ...
path: str, destdir: StrPath | None = None, include_py_files: bool = False
) -> list[tuple[str, str]]: ...
def copy_metadata(package_name: str, recursive: bool = ...) -> list[tuple[str, str]]: ...
def copy_metadata(package_name: str, recursive: bool = False) -> list[tuple[str, str]]: ...
def get_installer(module: str) -> str | None: ...
def requirements_for_package(package_name: str) -> list[str]: ...
def collect_all(
package_name: str,
include_py_files: bool = ...,
filter_submodules: Callable[[str], bool] | None = ...,
exclude_datas: Iterable[str] | None = ...,
include_datas: Iterable[str] | None = ...,
on_error: Literal["ignore", "warn once", "warn", "raise"] = ...,
include_py_files: bool = True,
filter_submodules: Callable[[str], bool] | None = None,
exclude_datas: Iterable[str] | None = None,
include_datas: Iterable[str] | None = None,
on_error: Literal["ignore", "warn once", "warn", "raise"] = "warn once",
) -> tuple[list[tuple[str, str]], list[tuple[str, str]], list[str]]: ...
def collect_entry_point(name: str) -> tuple[tuple[str, str], list[str]]: ...
def get_hook_config(hook_api: PostGraphAPI, module_name: str, key: str) -> None: ...
def include_or_exclude_file(
filename: StrOrBytesPath,
include_list: Iterable[StrOrBytesPath] | None = ...,
exclude_list: Iterable[StrOrBytesPath] | None = ...,
include_list: Iterable[StrOrBytesPath] | None = None,
exclude_list: Iterable[StrOrBytesPath] | None = None,
) -> bool: ...
def collect_delvewheel_libs_directory(
package_name: str,
libdir_name: StrPath | None = ...,
datas: list[tuple[str, str]] | None = ...,
binaries: list[tuple[str, str]] | None = ...,
libdir_name: StrPath | None = None,
datas: list[tuple[str, str]] | None = None,
binaries: list[tuple[str, str]] | None = None,
) -> tuple[list[tuple[str, str]], list[tuple[str, str]]]: ...
18 changes: 9 additions & 9 deletions stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import sys
from _typeshed import StrOrBytesPath
from collections.abc import Iterable
from pathlib import Path, PurePosixPath
from typing_extensions import TypedDict
from typing_extensions import Final, TypedDict

if sys.version_info >= (3, 8):
from importlib.metadata import PackagePath as _PackagePath
else:
# Same as importlib_metadata.PackagePath
class _PackagePath(PurePosixPath):
def read_text(self, encoding: str = ...) -> str: ...
def read_text(self, encoding: str = "utf-8") -> str: ...
def read_binary(self) -> str: ...
def locate(self) -> Path: ...

CONDA_ROOT: Path
CONDA_META_DIR: Path
PYTHONPATH_PREFIXES: list[Path]
CONDA_ROOT: Final[Path]
CONDA_META_DIR: Final[Path]
PYTHONPATH_PREFIXES: Final[list[Path]]

class _RawDict(TypedDict):
name: str
Expand Down Expand Up @@ -45,11 +45,11 @@ package_distribution = Distribution.from_package_name
class PackagePath(_PackagePath):
def locate(self) -> Path: ...

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

distributions: dict[str, Distribution]
Expand Down
6 changes: 3 additions & 3 deletions stubs/pyinstaller/pyi_splash/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Referenced in: https://pyinstaller.org/en/stable/advanced-topics.html#module-pyi_splash
# Source: https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/fake-modules/pyi_splash.py
from typing_extensions import Literal
from typing_extensions import Final

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

def is_alive() -> bool: ...
def update_text(msg: str) -> None: ...
def close() -> None: ...

CLOSE_CONNECTION: Literal[b"\x04"]
FLUSH_CHARACTER: Literal[b"\r"]
CLOSE_CONNECTION: Final = b"\x04"
FLUSH_CHARACTER: Final = b"\x0D"