From 3b218bbc7c128da493b222baa9f92cf1a3821dec Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 4 Sep 2022 23:14:24 -0400 Subject: [PATCH 01/18] Added PyInstaller stubs for all documented modules & packages https://pyinstaller.org/en/stable/usage.html https://pyinstaller.org/en/stable/hooks.html https://pyinstaller.org/en/stable/hooks-config.html https://pyinstaller.org/en/stable/advanced-topics.html https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/fake-modules/pyi_splash.py All `__all__` from documented modules & packages --- .../pyinstaller/@tests/stubtest_allowlist.txt | 4 + stubs/pyinstaller/METADATA.toml | 6 ++ stubs/pyinstaller/PyInstaller/__init__.pyi | 11 +++ stubs/pyinstaller/PyInstaller/__main__.pyi | 11 +++ .../PyInstaller/building/build_main.pyi | 28 +++++++ .../PyInstaller/building/datastruct.pyi | 27 ++++++ stubs/pyinstaller/PyInstaller/compat.pyi | 81 ++++++++++++++++++ .../PyInstaller/depend/imphookapi.pyi | 13 +++ .../PyInstaller/isolated/__init__.pyi | 2 + .../PyInstaller/isolated/_parent.pyi | 14 ++++ .../PyInstaller/utils/__init__.pyi | 0 .../PyInstaller/utils/hooks/__init__.pyi | 82 +++++++++++++++++++ .../PyInstaller/utils/hooks/conda.pyi | 49 +++++++++++ .../PyInstaller/utils/hooks/win32.pyi | 3 + stubs/pyinstaller/pyi_splash/__init__.pyi | 12 +++ 15 files changed, 343 insertions(+) create mode 100644 stubs/pyinstaller/@tests/stubtest_allowlist.txt create mode 100644 stubs/pyinstaller/METADATA.toml create mode 100644 stubs/pyinstaller/PyInstaller/__init__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/__main__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/building/build_main.pyi create mode 100644 stubs/pyinstaller/PyInstaller/building/datastruct.pyi create mode 100644 stubs/pyinstaller/PyInstaller/compat.pyi create mode 100644 stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi create mode 100644 stubs/pyinstaller/PyInstaller/isolated/__init__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/isolated/_parent.pyi create mode 100644 stubs/pyinstaller/PyInstaller/utils/__init__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi create mode 100644 stubs/pyinstaller/PyInstaller/utils/hooks/win32.pyi create mode 100644 stubs/pyinstaller/pyi_splash/__init__.pyi diff --git a/stubs/pyinstaller/@tests/stubtest_allowlist.txt b/stubs/pyinstaller/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..4cda915e5e46 --- /dev/null +++ b/stubs/pyinstaller/@tests/stubtest_allowlist.txt @@ -0,0 +1,4 @@ +# fake module, only exists once the app is frozen +pyi_splash +# New, not yet published +PyInstaller.utils.hooks.include_or_exclude_file diff --git a/stubs/pyinstaller/METADATA.toml b/stubs/pyinstaller/METADATA.toml new file mode 100644 index 000000000000..03ac3e3c514e --- /dev/null +++ b/stubs/pyinstaller/METADATA.toml @@ -0,0 +1,6 @@ +version = "5.3.*" +requires = ["types-setuptools"] + +[tool.stubtest] +# Most modules are not meant to be used, yet are not marked as private +ignore_missing_stub = true diff --git a/stubs/pyinstaller/PyInstaller/__init__.pyi b/stubs/pyinstaller/PyInstaller/__init__.pyi new file mode 100644 index 000000000000..2aa6f67789f2 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/__init__.pyi @@ -0,0 +1,11 @@ +from typing_extensions import 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 diff --git a/stubs/pyinstaller/PyInstaller/__main__.pyi b/stubs/pyinstaller/PyInstaller/__main__.pyi new file mode 100644 index 000000000000..3e4b32ea45f9 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/__main__.pyi @@ -0,0 +1,11 @@ +# https://pyinstaller.org/en/stable/usage.html#running-pyinstaller-from-python-code +from _typeshed import SupportsKeysAndGetItem +from collections.abc import Iterable +from typing_extensions import TypeAlias + +# Used to update PyInstaller.config.CONF +_PyIConfig: TypeAlias = ( + SupportsKeysAndGetItem[str, bool | str | list[str] | None] | Iterable[tuple[str, bool | str | list[str] | None]] +) + +def run(pyi_args: Iterable[str] | None = ..., pyi_config: _PyIConfig | None = ...) -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/building/build_main.pyi b/stubs/pyinstaller/PyInstaller/building/build_main.pyi new file mode 100644 index 000000000000..ed8afa7cb874 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/building/build_main.pyi @@ -0,0 +1,28 @@ +# Referenced in: https://pyinstaller.org/en/stable/hooks.html?highlight=get_hook_config#PyInstaller.utils.hooks.get_hook_config +# Not to be imported during runtime, but is the type reference for hooks and analysis configuration + +from _typeshed import StrOrBytesPath +from collections.abc import Iterable + +from PyInstaller.building.datastruct import Target # type: ignore[import] + +class Analysis(Target): + # https://pyinstaller.org/en/stable/hooks-config.html#hook-configuration-options + hooksconfig: dict[str, dict[str, object]] + def __init__( + self, + scripts: Iterable[StrOrBytesPath], + pathex=..., + binaries=..., + datas=..., + hiddenimports=..., + hookspath=..., + hooksconfig: dict[str, dict[str, object]] | None = ..., + excludes=..., + runtime_hooks=..., + cipher=..., + win_no_prefer_redirects: bool = ..., + win_private_assemblies: bool = ..., + noarchive: bool = ..., + module_collection_mode=..., + ) -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi new file mode 100644 index 000000000000..a46d0d2e62c6 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi @@ -0,0 +1,27 @@ +# https://pyinstaller.org/en/stable/advanced-topics.html#the-toc-and-tree-classes +from collections.abc import Iterable, Sequence +from typing import ClassVar +from typing_extensions import Literal, LiteralString, TypeAlias + +_TypeCode: TypeAlias = Literal["DATA", "BINARY", "EXTENSION", "OPTION"] +_TOCTuple: TypeAlias = tuple[str, str | None, _TypeCode | None] + +class TOC(list[_TOCTuple]): + filenames: set[str] + def __init__(self, initlist: Iterable[_TOCTuple] | None = ...) -> None: ... + +class Target: + invcnum: ClassVar[int] + tocfilename: LiteralString + tocbasename: LiteralString + dependencies: TOC + +class Tree(Target, TOC): + root: str | None + prefix: str | None + excludes: list[str] | None + typecode: _TypeCode + def __init__( + self, root: str | None = ..., prefix: str | None = ..., excludes: Sequence[str] | None = ..., typecode: _TypeCode = ... + ) -> None: ... + def assemble(self) -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/compat.pyi b/stubs/pyinstaller/PyInstaller/compat.pyi new file mode 100644 index 000000000000..d157b10ffae8 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/compat.pyi @@ -0,0 +1,81 @@ +# https://pyinstaller.org/en/stable/hooks.html#module-PyInstaller.compat +from _typeshed import GenericPath, StrOrBytesPath +from collections.abc import Iterable +from importlib.abc import _Path +from types import ModuleType +from typing import AnyStr, overload +from typing_extensions import Literal, TypeAlias + +_OpenFile: TypeAlias = StrOrBytesPath | int + +is_64bits: bool +is_py35: bool +is_py36: bool +is_py37: bool +is_py38: bool +is_py39: bool +is_py310: 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: tuple[int, ...] | bool | None +is_macos_11_native: tuple[int, ...] | bool | None +is_macos_11: tuple[int, ...] | bool | None +PYDYLIB_NAMES: set[str] +base_prefix: str +is_venv: 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] + +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 + +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 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 +) -> 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 +) -> str: ... +def exec_command_all( + *cmdargs: str, encoding: str | 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 importlib_load_source(name: str, pathname: _Path) -> 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] + +def check_requirements() -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi new file mode 100644 index 000000000000..3e930af30e69 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi @@ -0,0 +1,13 @@ +# https://pyinstaller.org/en/stable/hooks-config.html `hook_api` is a PostGraphAPI + +from _typeshed import StrOrBytesPath +from collections.abc import Iterable + +from PyInstaller.building.build_main import Analysis # type: ignore[import] + +class PostGraphAPI: + @property + def __path__(self) -> tuple[str, ...] | None: ... + @property + def analysis(self) -> Analysis: ... + def add_datas(self, list_of_tuples: Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/isolated/__init__.pyi b/stubs/pyinstaller/PyInstaller/isolated/__init__.pyi new file mode 100644 index 000000000000..6f084bfc40ea --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/isolated/__init__.pyi @@ -0,0 +1,2 @@ +# https://pyinstaller.org/en/stable/hooks.html#module-PyInstaller.isolated +from PyInstaller.isolated._parent import Python as Python, call as call, decorate as decorate diff --git a/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi new file mode 100644 index 000000000000..1ac2f8e64257 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi @@ -0,0 +1,14 @@ +from collections.abc import Callable +from functools import _AnyCallable +from typing import TypeVar +from typing_extensions import ParamSpec + +_AC = TypeVar("_AC", bound=_AnyCallable) +_R = TypeVar("_R") +_P = ParamSpec("_P") + +class Python: + def call(self, function: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... + +def call(function: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... +def decorate(function: _AC) -> _AC: ... diff --git a/stubs/pyinstaller/PyInstaller/utils/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi new file mode 100644 index 000000000000..8da27b3eb05c --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi @@ -0,0 +1,82 @@ +# https://pyinstaller.org/en/stable/hooks.html + +import os +from _typeshed import AnyOrLiteralStr, StrOrBytesPath, SupportsKeysAndGetItem +from collections.abc import Callable, Iterable +from typing import Any, AnyStr +from typing_extensions import Literal, TypeAlias + +import pkg_resources +from PyInstaller import isolated +from PyInstaller.depend.imphookapi import PostGraphAPI # type: ignore[import] +from PyInstaller.utils.hooks import conda as conda_support +from PyInstaller.utils.hooks.win32 import get_pywin32_module_file_attribute as get_pywin32_module_file_attribute + +_Environ: TypeAlias = SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] | os._Environ[str] + +PY_IGNORE_EXTENSIONS: set[str] +hook_variables: dict[str, str] + +def exec_statement(statement: str) -> str | int: ... +def exec_statement_rc(statement: str) -> str | int: ... +def exec_script(script_filename: os.PathLike[AnyStr] | AnyOrLiteralStr, *args: str, env: _Environ | None = ...) -> str | int: ... +def exec_script_rc( + script_filename: os.PathLike[AnyStr] | AnyOrLiteralStr, *args: str, env: _Environ | None = ... +) -> str | int: ... +def eval_statement(statement: str) -> Any | Literal[""]: ... +def eval_script( + scriptfilename: os.PathLike[AnyStr] | AnyOrLiteralStr, *args: str, env: _Environ | None = ... +) -> Any | Literal[""]: ... +@isolated.decorate +def get_pyextension_imports(module_name: str) -> list[str]: ... +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: ... +@isolated.decorate +def can_import_module(module_name: str) -> bool: ... +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 = ..., +) -> 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"] = ... +) -> list[str]: ... +def is_module_or_submodule(name: str, mod_or_submod: str) -> bool: ... + +PY_DYLIB_PATTERNS: list[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: StrOrBytesPath | None = ..., + excludes: Iterable[str] | None = ..., + includes: Iterable[str] | None = ..., +) -> list[tuple[str, str]]: ... +def collect_system_data_files( + path: str, destdir: StrOrBytesPath | None = ..., include_py_files: bool = ... +) -> list[tuple[str, str]]: ... +def copy_metadata(package_name: str, recursive: bool = ...) -> 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"] = ..., +) -> 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: str, include_list: Iterable[str] | None = ..., exclude_list: Iterable[str] | None = ... +) -> bool: ... diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi new file mode 100644 index 000000000000..349630c7fe00 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi @@ -0,0 +1,49 @@ +# https://pyinstaller.org/en/stable/hooks.html?highlight=conda_support#module-PyInstaller.utils.hooks.conda + +import sys +from _typeshed import StrOrBytesPath +from collections.abc import Sequence +from pathlib import Path, PurePath +from typing import Any +from typing_extensions import TypeAlias, TypedDict + +if sys.version_info >= (3, 8): + from importlib.metadata import PackagePath as _PackagePath +else: + _PackagePath: TypeAlias = Any + +CONDA_ROOT: Path +CONDA_META_DIR: Path +PYTHONPATH_PREFIXES: list[Path] + +class _RawDict(TypedDict): + name: str + version: str + files: list[StrOrBytesPath | PurePath] + depends: list[str] + +class Distribution: + raw: _RawDict + name: str + version: str + files: list[PackagePath] + dependencies: list[str] + packages: list[str | None] + def __init__(self, json_path: str) -> None: ... + @classmethod + def from_name(cls, name: str) -> Distribution: ... + @classmethod + def from_package_name(cls, name: str) -> Distribution: ... + +class PackagePath(_PackagePath): + def locate(self) -> Path: ... + +def walk_dependency_tree(initial: str, excludes: Sequence[str] | None = ...) -> dict[str, Distribution]: ... +def requires(name: str, strip_versions: bool = ...) -> list[str]: ... +def files(name: str, dependencies: bool = ..., excludes: Sequence[str] | None = ...) -> list[PackagePath]: ... +def collect_dynamic_libs( + name: str, dest: str = ..., dependencies: bool = ..., excludes: Sequence[str] | None = ... +) -> list[tuple[str, str]]: ... + +distributions: dict[str, Distribution] +distributions_by_package: dict[str | None, Distribution] diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/win32.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/win32.pyi new file mode 100644 index 000000000000..105eb1f5b964 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/win32.pyi @@ -0,0 +1,3 @@ +__all__ = ("get_pywin32_module_file_attribute",) + +def get_pywin32_module_file_attribute(module_name: str) -> str | int: ... diff --git a/stubs/pyinstaller/pyi_splash/__init__.pyi b/stubs/pyinstaller/pyi_splash/__init__.pyi new file mode 100644 index 000000000000..66381afe4c39 --- /dev/null +++ b/stubs/pyinstaller/pyi_splash/__init__.pyi @@ -0,0 +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 + +__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"\u0004"] +FLUSH_CHARACTER: Literal[b"\r"] From a0b204a1ae905d506441f8c439caac4619afba4f Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 12 Sep 2022 13:45:26 -0400 Subject: [PATCH 02/18] Remove not yet published method --- stubs/pyinstaller/@tests/stubtest_allowlist.txt | 2 -- stubs/pyinstaller/PyInstaller/building/datastruct.pyi | 2 +- stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi | 3 --- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/stubs/pyinstaller/@tests/stubtest_allowlist.txt b/stubs/pyinstaller/@tests/stubtest_allowlist.txt index 4cda915e5e46..423974ce4593 100644 --- a/stubs/pyinstaller/@tests/stubtest_allowlist.txt +++ b/stubs/pyinstaller/@tests/stubtest_allowlist.txt @@ -1,4 +1,2 @@ # fake module, only exists once the app is frozen pyi_splash -# New, not yet published -PyInstaller.utils.hooks.include_or_exclude_file diff --git a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi index a46d0d2e62c6..c7360481c4dd 100644 --- a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi +++ b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi @@ -19,7 +19,7 @@ class Target: class Tree(Target, TOC): root: str | None prefix: str | None - excludes: list[str] | None + excludes: Sequence[str] typecode: _TypeCode def __init__( self, root: str | None = ..., prefix: str | None = ..., excludes: Sequence[str] | None = ..., typecode: _TypeCode = ... diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi index 8da27b3eb05c..21ec1dd87932 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi @@ -77,6 +77,3 @@ def collect_all( ) -> 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: str, include_list: Iterable[str] | None = ..., exclude_list: Iterable[str] | None = ... -) -> bool: ... From 3801205f8721448ea0673e3accb586685fdc93c8 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 12 Sep 2022 14:05:44 -0400 Subject: [PATCH 03/18] Some missed --- stubs/pyinstaller/PyInstaller/compat.pyi | 1 + stubs/pyinstaller/PyInstaller/isolated/_parent.pyi | 6 +++++- stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi | 2 +- stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi | 4 ++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stubs/pyinstaller/PyInstaller/compat.pyi b/stubs/pyinstaller/PyInstaller/compat.pyi index d157b10ffae8..ff08447e1c10 100644 --- a/stubs/pyinstaller/PyInstaller/compat.pyi +++ b/stubs/pyinstaller/PyInstaller/compat.pyi @@ -34,6 +34,7 @@ is_macos_11: tuple[int, ...] | bool | None PYDYLIB_NAMES: set[str] base_prefix: str is_venv: bool +is_virtualenv: bool is_conda: bool is_pure_conda: bool python_executable: str diff --git a/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi index 1ac2f8e64257..7996509bd43f 100644 --- a/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi +++ b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi @@ -1,5 +1,7 @@ +from _typeshed import Self from collections.abc import Callable from functools import _AnyCallable +from types import TracebackType from typing import TypeVar from typing_extensions import ParamSpec @@ -7,7 +9,9 @@ _AC = TypeVar("_AC", bound=_AnyCallable) _R = TypeVar("_R") _P = ParamSpec("_P") -class Python: +class Python + def __enter__(self: Self) -> Self: ... + def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> None: ... def call(self, function: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... def call(function: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi index 21ec1dd87932..8c67809cbe55 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi @@ -7,7 +7,7 @@ from typing import Any, AnyStr from typing_extensions import Literal, TypeAlias import pkg_resources -from PyInstaller import isolated +from PyInstaller import HOMEPATH as HOMEPATH, isolated from PyInstaller.depend.imphookapi import PostGraphAPI # type: ignore[import] from PyInstaller.utils.hooks import conda as conda_support from PyInstaller.utils.hooks.win32 import get_pywin32_module_file_attribute as get_pywin32_module_file_attribute diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi index 349630c7fe00..5e0bb4911643 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi @@ -35,6 +35,10 @@ class Distribution: @classmethod def from_package_name(cls, name: str) -> Distribution: ... +# distribution and package_distribution are meant to be used and are not internal helpers +distribution = Distribution.from_name +package_distribution = Distribution.from_package_name + class PackagePath(_PackagePath): def locate(self) -> Path: ... From dd58adc7f4ebff6b19ac854b7a2c71f43dff25e0 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 12 Sep 2022 14:18:06 -0400 Subject: [PATCH 04/18] Missed : --- stubs/pyinstaller/PyInstaller/isolated/_parent.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi index 7996509bd43f..a0127817c9d4 100644 --- a/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi +++ b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi @@ -9,7 +9,7 @@ _AC = TypeVar("_AC", bound=_AnyCallable) _R = TypeVar("_R") _P = ParamSpec("_P") -class Python +class Python: def __enter__(self: Self) -> Self: ... def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> None: ... def call(self, function: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... From e445beac8c4166b594f34b72bcd21c2574a82fca Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 12 Sep 2022 14:32:37 -0400 Subject: [PATCH 05/18] Make scale of ignore_missing_stub clear in comment --- stubs/pyinstaller/METADATA.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/pyinstaller/METADATA.toml b/stubs/pyinstaller/METADATA.toml index 03ac3e3c514e..fd1afaf4196f 100644 --- a/stubs/pyinstaller/METADATA.toml +++ b/stubs/pyinstaller/METADATA.toml @@ -3,4 +3,5 @@ requires = ["types-setuptools"] [tool.stubtest] # Most modules are not meant to be used, yet are not marked as private +# Otherwise results in 138 "failed to find stubs" and 8 "is not present in stub" ignore_missing_stub = true From 28cee78c910b02a086b2dcc577f79b7554721560 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 Sep 2022 17:06:45 -0400 Subject: [PATCH 06/18] __init__ --- stubs/pyinstaller/PyInstaller/building/__init__.pyi | 0 stubs/pyinstaller/PyInstaller/building/build_main.pyi | 2 +- stubs/pyinstaller/PyInstaller/depend/__init__.pyi | 0 stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi | 2 +- stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 stubs/pyinstaller/PyInstaller/building/__init__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/depend/__init__.pyi diff --git a/stubs/pyinstaller/PyInstaller/building/__init__.pyi b/stubs/pyinstaller/PyInstaller/building/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/pyinstaller/PyInstaller/building/build_main.pyi b/stubs/pyinstaller/PyInstaller/building/build_main.pyi index ed8afa7cb874..bfba4b2464b1 100644 --- a/stubs/pyinstaller/PyInstaller/building/build_main.pyi +++ b/stubs/pyinstaller/PyInstaller/building/build_main.pyi @@ -4,7 +4,7 @@ from _typeshed import StrOrBytesPath from collections.abc import Iterable -from PyInstaller.building.datastruct import Target # type: ignore[import] +from PyInstaller.building.datastruct import Target class Analysis(Target): # https://pyinstaller.org/en/stable/hooks-config.html#hook-configuration-options diff --git a/stubs/pyinstaller/PyInstaller/depend/__init__.pyi b/stubs/pyinstaller/PyInstaller/depend/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi index 3e930af30e69..7a8b89a76c5b 100644 --- a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi @@ -3,7 +3,7 @@ from _typeshed import StrOrBytesPath from collections.abc import Iterable -from PyInstaller.building.build_main import Analysis # type: ignore[import] +from PyInstaller.building.build_main import Analysis class PostGraphAPI: @property diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi index 8c67809cbe55..fbb304344db0 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi @@ -8,7 +8,7 @@ from typing_extensions import Literal, TypeAlias import pkg_resources from PyInstaller import HOMEPATH as HOMEPATH, isolated -from PyInstaller.depend.imphookapi import PostGraphAPI # type: ignore[import] +from PyInstaller.depend.imphookapi import PostGraphAPI from PyInstaller.utils.hooks import conda as conda_support from PyInstaller.utils.hooks.win32 import get_pywin32_module_file_attribute as get_pywin32_module_file_attribute From 925152b45d67e6557c8d1b22f7fc98c89c00fca9 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 Sep 2022 23:32:16 -0400 Subject: [PATCH 07/18] Complete imphookapi with missing documented parts --- stubs/pyinstaller/METADATA.toml | 2 +- .../PyInstaller/building/datastruct.pyi | 5 +- .../PyInstaller/depend/analysis.pyi | 5 ++ .../PyInstaller/depend/imphookapi.pyi | 71 +++++++++++++++++-- .../pyinstaller/PyInstaller/lib/__init__.pyi | 0 .../PyInstaller/lib/modulegraph/__init__.pyi | 0 .../lib/modulegraph/modulegraph.pyi | 32 +++++++++ 7 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 stubs/pyinstaller/PyInstaller/depend/analysis.pyi create mode 100644 stubs/pyinstaller/PyInstaller/lib/__init__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/lib/modulegraph/__init__.pyi create mode 100644 stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi diff --git a/stubs/pyinstaller/METADATA.toml b/stubs/pyinstaller/METADATA.toml index fd1afaf4196f..a745b0b0703f 100644 --- a/stubs/pyinstaller/METADATA.toml +++ b/stubs/pyinstaller/METADATA.toml @@ -3,5 +3,5 @@ requires = ["types-setuptools"] [tool.stubtest] # Most modules are not meant to be used, yet are not marked as private -# Otherwise results in 138 "failed to find stubs" and 8 "is not present in stub" +# Otherwise results in 129 "failed to find stubs" and 109 "is not present in stub" ignore_missing_stub = true diff --git a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi index c7360481c4dd..4edcd586044e 100644 --- a/stubs/pyinstaller/PyInstaller/building/datastruct.pyi +++ b/stubs/pyinstaller/PyInstaller/building/datastruct.pyi @@ -1,7 +1,7 @@ # https://pyinstaller.org/en/stable/advanced-topics.html#the-toc-and-tree-classes from collections.abc import Iterable, Sequence from typing import ClassVar -from typing_extensions import Literal, LiteralString, TypeAlias +from typing_extensions import Literal, LiteralString, SupportsIndex, TypeAlias _TypeCode: TypeAlias = Literal["DATA", "BINARY", "EXTENSION", "OPTION"] _TOCTuple: TypeAlias = tuple[str, str | None, _TypeCode | None] @@ -9,6 +9,9 @@ _TOCTuple: TypeAlias = tuple[str, str | None, _TypeCode | None] class TOC(list[_TOCTuple]): filenames: set[str] def __init__(self, initlist: Iterable[_TOCTuple] | None = ...) -> None: ... + def append(self, entry: _TOCTuple) -> None: ... + def insert(self, pos: SupportsIndex, entry: _TOCTuple) -> None: ... + def extend(self, other: Iterable[_TOCTuple]) -> None: ... class Target: invcnum: ClassVar[int] diff --git a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi new file mode 100644 index 000000000000..29632822f407 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi @@ -0,0 +1,5 @@ +# https://pyinstaller.org/en/stable/hooks.html#the-pre-safe-import-module-psim-api-method + +# The documentation explicitely mentions that "Normally you do not need to know about the module-graph." +# However, some PyiModuleGraph typed class attributes are still documented as existing in imphookapi. +class PyiModuleGraph: ... # incomplete diff --git a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi index 7a8b89a76c5b..bb287c0ec57f 100644 --- a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi @@ -1,13 +1,76 @@ -# https://pyinstaller.org/en/stable/hooks-config.html `hook_api` is a PostGraphAPI +# https://pyinstaller.org/en/stable/hooks-config.html#adding-an-option-to-the-hook `hook_api` is a PostGraphAPI +# Nothing in this module is meant to be initialized externally. +# Instances are exposed through hooks during build. from _typeshed import StrOrBytesPath -from collections.abc import Iterable +from collections.abc import Generator, Iterable +from typing import Any +from typing_extensions import Literal, LiteralString from PyInstaller.building.build_main import Analysis +from PyInstaller.building.datastruct import TOC +from PyInstaller.depend.analysis import PyiModuleGraph +from PyInstaller.lib.modulegraph.modulegraph import Package +# https://pyinstaller.org/en/stable/hooks.html#the-pre-safe-import-module-psim-api-method +class PreSafeImportModuleAPI: + module_basename: LiteralString + module_name: LiteralString + def __init__( + self, + module_graph: PyiModuleGraph, + module_basename: LiteralString, + module_name: LiteralString, + parent_package: Package | None, + ) -> None: ... + @property + def module_graph(self) -> PyiModuleGraph: ... + @property + def parent_package(self) -> Package | None: ... + def add_runtime_module(self, module_name: str) -> None: ... + def add_runtime_package(self, package_name: str) -> None: ... + def add_alias_module(self, real_module_name: str, alias_module_name: str) -> None: ... + def append_package_path(self, directory) -> None: ... + +# https://pyinstaller.org/en/stable/hooks.html#the-pre-find-module-path-pfmp-api-method +class PreFindModulePathAPI: + search_dirs: Iterable[StrOrBytesPath] = ... + def __init__( + self, module_graph: PyiModuleGraph, module_name: LiteralString, search_dirs: Iterable[StrOrBytesPath] + ) -> None: ... + @property + def module_graph(self) -> PyiModuleGraph: ... + @property + def module_name(self) -> LiteralString: ... + +# https://pyinstaller.org/en/stable/hooks.html#the-hook-hook-api-function class PostGraphAPI: + module_graph: PyiModuleGraph + module: Package + def __init__(self, module_name: LiteralString, module_graph: PyiModuleGraph, analysis: Analysis) -> None: ... + @property + def __file__(self) -> LiteralString: ... @property - def __path__(self) -> tuple[str, ...] | None: ... + def __path__(self) -> tuple[LiteralString, ...] | None: ... + @property + def __name__(self) -> LiteralString: ... + # Compiled code. See stdlib.builtins.compile + @property + def co(self) -> Any: ... @property def analysis(self) -> Analysis: ... - def add_datas(self, list_of_tuples: Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... + @property + def name(self) -> LiteralString: ... + @property + def graph(self) -> PyiModuleGraph: ... + @property + def node(self) -> Package: ... + @property + def imports(self) -> Generator[Package, None, None]: ... + def add_imports(self, *module_names: str) -> None: ... + def del_imports(self, *module_names: str) -> None: ... + def add_binaries(self, list_of_tuples: TOC | Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... + def add_datas(self, list_of_tuples: TOC | Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... + def set_module_collection_mode( + self, name: str | None, mode: Literal["pyz", "pyc", "py", "pyz+py", "py+pyz"] | None + ) -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/lib/__init__.pyi b/stubs/pyinstaller/PyInstaller/lib/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/pyinstaller/PyInstaller/lib/modulegraph/__init__.pyi b/stubs/pyinstaller/PyInstaller/lib/modulegraph/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi new file mode 100644 index 000000000000..85752a55c806 --- /dev/null +++ b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi @@ -0,0 +1,32 @@ +from typing import Any +from typing_extensions import LiteralString + +# TODO: For typing purposes, once #5768 is complete, it'll be easier to use the modulegraph package directly. + +# code, filename and packagepath are always initialized to None. But they can be given a value later. +class Node: + # Compiled code. See stdlib.builtins.compile + code: Any | None + filename: LiteralString | None + graphident: LiteralString + identifier: LiteralString + packagepath: LiteralString | None + def __init__(self, identifier: LiteralString) -> None: ... + def is_global_attr(self, attr_name: str) -> bool: ... + def is_submodule(self, submodule_basename: str) -> bool: ... + def add_global_attr(self, attr_name: str) -> None: ... + def add_global_attrs_from_module(self, target_module: Node) -> None: ... + def add_submodule(self, submodule_basename: str, submodule_node: Node) -> None: ... + def get_submodule(self, submodule_basename: str) -> Node: ... + def get_submodule_or_none(self, submodule_basename: str) -> Node | None: ... + def remove_global_attr_if_found(self, attr_name: str) -> None: ... + def infoTuple(self) -> tuple[LiteralString]: ... + +class BaseModule(Node): + filename: LiteralString + packagepath: LiteralString + def __init__(self, name: LiteralString, filename: LiteralString | None = ..., path: LiteralString | None = ...) -> None: ... + # Returns a tuple of length 0, 1, 2, or 3 + def infoTuple(self) -> tuple[LiteralString, ...]: ... # type: ignore[override] + +class Package(BaseModule): ... From 9e54a3024d1b2d120ff6531f1113d15ee5fbac39 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 Sep 2022 23:35:30 -0400 Subject: [PATCH 08/18] missed type for parameter "directory" --- stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi index bb287c0ec57f..efa961cf14e2 100644 --- a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi @@ -30,7 +30,7 @@ class PreSafeImportModuleAPI: def add_runtime_module(self, module_name: str) -> None: ... def add_runtime_package(self, package_name: str) -> None: ... def add_alias_module(self, real_module_name: str, alias_module_name: str) -> None: ... - def append_package_path(self, directory) -> None: ... + def append_package_path(self, directory: str) -> None: ... # https://pyinstaller.org/en/stable/hooks.html#the-pre-find-module-path-pfmp-api-method class PreFindModulePathAPI: From 72788598d751f8803e2cf75b9d9cefc38c59e2b2 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 Sep 2022 23:43:10 -0400 Subject: [PATCH 09/18] Fix "stub does not have argument" --- stubs/pyinstaller/PyInstaller/depend/analysis.pyi | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi index 29632822f407..0e85ec217e4c 100644 --- a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi @@ -2,4 +2,17 @@ # The documentation explicitely mentions that "Normally you do not need to know about the module-graph." # However, some PyiModuleGraph typed class attributes are still documented as existing in imphookapi. -class PyiModuleGraph: ... # incomplete +from _typeshed import Incomplete + +class PyiModuleGraph: # incomplete + def __init__( + self, + pyi_homepath, + user_hook_dirs=..., + excludes=..., + path: Incomplete | None = ..., + replace_paths=..., + implies=..., + graph: Incomplete | None = ..., + debug: int = ..., + ) -> None: ... From e35ee77799e38cabe782c90602d9f26dde9a17a7 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 Sep 2022 23:51:13 -0400 Subject: [PATCH 10/18] pyi_homepath path --- stubs/pyinstaller/PyInstaller/depend/analysis.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi index 0e85ec217e4c..bcfd30ee929f 100644 --- a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi @@ -3,11 +3,12 @@ # The documentation explicitely mentions that "Normally you do not need to know about the module-graph." # However, some PyiModuleGraph typed class attributes are still documented as existing in imphookapi. from _typeshed import Incomplete +from typing_extensions import LiteralString class PyiModuleGraph: # incomplete def __init__( self, - pyi_homepath, + pyi_homepath: LiteralString, user_hook_dirs=..., excludes=..., path: Incomplete | None = ..., From 69e18c5d7ff9ec04d53b93c0805668ea396e7fed Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 14 Sep 2022 00:12:55 -0400 Subject: [PATCH 11/18] PyInstaller.depend.analysis.PyiModuleGraph.__init__ --- stubs/pyinstaller/@tests/stubtest_allowlist.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/pyinstaller/@tests/stubtest_allowlist.txt b/stubs/pyinstaller/@tests/stubtest_allowlist.txt index 423974ce4593..5217cbc762c3 100644 --- a/stubs/pyinstaller/@tests/stubtest_allowlist.txt +++ b/stubs/pyinstaller/@tests/stubtest_allowlist.txt @@ -1,2 +1,4 @@ # fake module, only exists once the app is frozen pyi_splash +# kwargs +PyInstaller.depend.analysis.PyiModuleGraph.__init__ From 927419e8ee54d8776f52b04606c04c46a0cb8a51 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 14 Sep 2022 22:06:29 -0400 Subject: [PATCH 12/18] PR review fixes --- stubs/pyinstaller/METADATA.toml | 2 +- .../PyInstaller/building/build_main.pyi | 3 ++- stubs/pyinstaller/PyInstaller/compat.pyi | 8 ++++---- .../PyInstaller/depend/imphookapi.pyi | 4 ++-- .../PyInstaller/isolated/_parent.pyi | 7 ++++--- .../lib/modulegraph/modulegraph.pyi | 11 +++++++++- .../PyInstaller/utils/hooks/__init__.pyi | 20 +++++++------------ .../PyInstaller/utils/hooks/conda.pyi | 14 ++++++------- 8 files changed, 37 insertions(+), 32 deletions(-) diff --git a/stubs/pyinstaller/METADATA.toml b/stubs/pyinstaller/METADATA.toml index a745b0b0703f..91995ca4fd39 100644 --- a/stubs/pyinstaller/METADATA.toml +++ b/stubs/pyinstaller/METADATA.toml @@ -3,5 +3,5 @@ requires = ["types-setuptools"] [tool.stubtest] # Most modules are not meant to be used, yet are not marked as private -# Otherwise results in 129 "failed to find stubs" and 109 "is not present in stub" +# Otherwise results in 129 "failed to find stubs" and 106 "is not present in stub" ignore_missing_stub = true diff --git a/stubs/pyinstaller/PyInstaller/building/build_main.pyi b/stubs/pyinstaller/PyInstaller/building/build_main.pyi index bfba4b2464b1..3e87e9c76cbe 100644 --- a/stubs/pyinstaller/PyInstaller/building/build_main.pyi +++ b/stubs/pyinstaller/PyInstaller/building/build_main.pyi @@ -3,6 +3,7 @@ from _typeshed import StrOrBytesPath from collections.abc import Iterable +from typing import Any from PyInstaller.building.datastruct import Target @@ -17,7 +18,7 @@ class Analysis(Target): datas=..., hiddenimports=..., hookspath=..., - hooksconfig: dict[str, dict[str, object]] | None = ..., + hooksconfig: dict[str, dict[str, Any]] | None = ..., excludes=..., runtime_hooks=..., cipher=..., diff --git a/stubs/pyinstaller/PyInstaller/compat.pyi b/stubs/pyinstaller/PyInstaller/compat.pyi index ff08447e1c10..e5e038b35384 100644 --- a/stubs/pyinstaller/PyInstaller/compat.pyi +++ b/stubs/pyinstaller/PyInstaller/compat.pyi @@ -1,12 +1,12 @@ # https://pyinstaller.org/en/stable/hooks.html#module-PyInstaller.compat -from _typeshed import GenericPath, StrOrBytesPath +from _typeshed import FileDescriptor, GenericPath, StrOrBytesPath from collections.abc import Iterable from importlib.abc import _Path from types import ModuleType from typing import AnyStr, overload from typing_extensions import Literal, TypeAlias -_OpenFile: TypeAlias = StrOrBytesPath | int +_OpenFile: TypeAlias = StrOrBytesPath | FileDescriptor is_64bits: bool is_py35: bool @@ -45,11 +45,11 @@ ALL_SUFFIXES: 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 +machine: 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: ... +def getenv(name: str, default: str) -> str: ... @overload def getenv(name: str, default: None = ...) -> str | None: ... def setenv(name: str, value: str) -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi index efa961cf14e2..d216820532cd 100644 --- a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi @@ -34,7 +34,7 @@ class PreSafeImportModuleAPI: # https://pyinstaller.org/en/stable/hooks.html#the-pre-find-module-path-pfmp-api-method class PreFindModulePathAPI: - search_dirs: Iterable[StrOrBytesPath] = ... + search_dirs: Iterable[StrOrBytesPath] def __init__( self, module_graph: PyiModuleGraph, module_name: LiteralString, search_dirs: Iterable[StrOrBytesPath] ) -> None: ... @@ -72,5 +72,5 @@ class PostGraphAPI: def add_binaries(self, list_of_tuples: TOC | Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... def add_datas(self, list_of_tuples: TOC | Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... def set_module_collection_mode( - self, name: str | None, mode: Literal["pyz", "pyc", "py", "pyz+py", "py+pyz"] | None + self, name: str | None, mode: Literal["pyz", "pyc", "py", "pyz+py", "py+pyz", None] ) -> None: ... diff --git a/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi index a0127817c9d4..ea9ee603e9f5 100644 --- a/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi +++ b/stubs/pyinstaller/PyInstaller/isolated/_parent.pyi @@ -1,17 +1,18 @@ from _typeshed import Self from collections.abc import Callable -from functools import _AnyCallable from types import TracebackType from typing import TypeVar from typing_extensions import ParamSpec -_AC = TypeVar("_AC", bound=_AnyCallable) +_AC = TypeVar("_AC", bound=Callable[..., object]) _R = TypeVar("_R") _P = ParamSpec("_P") class Python: def __enter__(self: Self) -> Self: ... - def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None) -> None: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... def call(self, function: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... def call(function: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... diff --git a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi index 85752a55c806..da2bb18397ad 100644 --- a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi +++ b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi @@ -1,5 +1,8 @@ from typing import Any -from typing_extensions import LiteralString +from typing_extensions import LiteralString, Protocol + +class _SupportsGraphident(Protocol): + graphident: str # TODO: For typing purposes, once #5768 is complete, it'll be easier to use the modulegraph package directly. @@ -20,6 +23,12 @@ class Node: def get_submodule(self, submodule_basename: str) -> Node: ... def get_submodule_or_none(self, submodule_basename: str) -> Node | None: ... def remove_global_attr_if_found(self, attr_name: str) -> None: ... + def __eq__(self, other: _SupportsGraphident) -> bool: ... + def __ne__(self, other: _SupportsGraphident) -> bool: ... + def __lt__(self, other: _SupportsGraphident) -> bool: ... + def __le__(self, other: _SupportsGraphident) -> bool: ... + def __gt__(self, other: _SupportsGraphident) -> bool: ... + def __ge__(self, other: _SupportsGraphident) -> bool: ... def infoTuple(self) -> tuple[LiteralString]: ... class BaseModule(Node): diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi index fbb304344db0..9637a91320f3 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi @@ -1,13 +1,13 @@ # https://pyinstaller.org/en/stable/hooks.html import os -from _typeshed import AnyOrLiteralStr, StrOrBytesPath, SupportsKeysAndGetItem +from _typeshed import StrOrBytesPath, SupportsKeysAndGetItem from collections.abc import Callable, Iterable -from typing import Any, AnyStr +from typing import Any from typing_extensions import Literal, TypeAlias import pkg_resources -from PyInstaller import HOMEPATH as HOMEPATH, isolated +from PyInstaller import HOMEPATH as HOMEPATH from PyInstaller.depend.imphookapi import PostGraphAPI from PyInstaller.utils.hooks import conda as conda_support from PyInstaller.utils.hooks.win32 import get_pywin32_module_file_attribute as get_pywin32_module_file_attribute @@ -19,21 +19,15 @@ hook_variables: dict[str, str] def exec_statement(statement: str) -> str | int: ... def exec_statement_rc(statement: str) -> str | int: ... -def exec_script(script_filename: os.PathLike[AnyStr] | AnyOrLiteralStr, *args: str, env: _Environ | None = ...) -> str | int: ... -def exec_script_rc( - script_filename: os.PathLike[AnyStr] | AnyOrLiteralStr, *args: str, env: _Environ | None = ... -) -> str | int: ... +def exec_script(script_filename: StrOrBytesPath, *args: str, env: _Environ | None = ...) -> str | int: ... +def exec_script_rc(script_filename: StrOrBytesPath, *args: str, env: _Environ | None = ...) -> str | int: ... def eval_statement(statement: str) -> Any | Literal[""]: ... -def eval_script( - scriptfilename: os.PathLike[AnyStr] | AnyOrLiteralStr, *args: str, env: _Environ | None = ... -) -> Any | Literal[""]: ... -@isolated.decorate +def eval_script(scriptfilename: StrOrBytesPath, *args: str, env: _Environ | None = ...) -> Any | Literal[""]: ... def get_pyextension_imports(module_name: str) -> list[str]: ... 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: ... -@isolated.decorate def can_import_module(module_name: str) -> bool: ... def get_module_attribute(module_name: str, attr_name: str) -> Any: ... def get_module_file_attribute(package: str) -> str | None: ... @@ -53,7 +47,7 @@ def is_module_or_submodule(name: str, mod_or_submod: str) -> bool: ... PY_DYLIB_PATTERNS: list[str] -def collect_dynamic_libs(package: str, destdir: object | None = ...) -> list[tuple[str, str]]: ... +def collect_dynamic_libs(package: str, destdir: object = ...) -> list[tuple[str, str]]: ... def collect_data_files( package: str, include_py_files: bool = ..., diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi index 5e0bb4911643..6801203e888a 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi @@ -2,8 +2,8 @@ import sys from _typeshed import StrOrBytesPath -from collections.abc import Sequence -from pathlib import Path, PurePath +from collections.abc import Iterable +from pathlib import Path from typing import Any from typing_extensions import TypeAlias, TypedDict @@ -19,7 +19,7 @@ PYTHONPATH_PREFIXES: list[Path] class _RawDict(TypedDict): name: str version: str - files: list[StrOrBytesPath | PurePath] + files: list[StrOrBytesPath] depends: list[str] class Distribution: @@ -28,7 +28,7 @@ class Distribution: version: str files: list[PackagePath] dependencies: list[str] - packages: list[str | None] + packages: list[str] def __init__(self, json_path: str) -> None: ... @classmethod def from_name(cls, name: str) -> Distribution: ... @@ -42,11 +42,11 @@ package_distribution = Distribution.from_package_name class PackagePath(_PackagePath): def locate(self) -> Path: ... -def walk_dependency_tree(initial: str, excludes: Sequence[str] | None = ...) -> dict[str, Distribution]: ... +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: Sequence[str] | None = ...) -> list[PackagePath]: ... +def files(name: str, dependencies: bool = ..., excludes: Iterable[str] | None = ...) -> list[PackagePath]: ... def collect_dynamic_libs( - name: str, dest: str = ..., dependencies: bool = ..., excludes: Sequence[str] | None = ... + name: str, dest: str = ..., dependencies: bool = ..., excludes: Iterable[str] | None = ... ) -> list[tuple[str, str]]: ... distributions: dict[str, Distribution] From 7019f09e74c5ef01a8fd55060f38f99a810aba5b Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 14 Sep 2022 22:20:16 -0400 Subject: [PATCH 13/18] __eq__ and __ne__ to work with arbitrary objects --- .../pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi index da2bb18397ad..f32b9b5698ed 100644 --- a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi +++ b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi @@ -1,5 +1,5 @@ -from typing import Any -from typing_extensions import LiteralString, Protocol +from typing import Any, Protocol +from typing_extensions import LiteralString class _SupportsGraphident(Protocol): graphident: str @@ -23,8 +23,6 @@ class Node: def get_submodule(self, submodule_basename: str) -> Node: ... def get_submodule_or_none(self, submodule_basename: str) -> Node | None: ... def remove_global_attr_if_found(self, attr_name: str) -> None: ... - def __eq__(self, other: _SupportsGraphident) -> bool: ... - def __ne__(self, other: _SupportsGraphident) -> bool: ... def __lt__(self, other: _SupportsGraphident) -> bool: ... def __le__(self, other: _SupportsGraphident) -> bool: ... def __gt__(self, other: _SupportsGraphident) -> bool: ... From 202d8577900176d4d39d1c84dd1488f4149e80f7 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 14 Sep 2022 23:43:46 -0400 Subject: [PATCH 14/18] 5.4 --- stubs/pyinstaller/METADATA.toml | 2 +- stubs/pyinstaller/PyInstaller/compat.pyi | 6 +++--- stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/stubs/pyinstaller/METADATA.toml b/stubs/pyinstaller/METADATA.toml index 91995ca4fd39..569772c9fbd0 100644 --- a/stubs/pyinstaller/METADATA.toml +++ b/stubs/pyinstaller/METADATA.toml @@ -1,4 +1,4 @@ -version = "5.3.*" +version = "5.4.*" requires = ["types-setuptools"] [tool.stubtest] diff --git a/stubs/pyinstaller/PyInstaller/compat.pyi b/stubs/pyinstaller/PyInstaller/compat.pyi index e5e038b35384..8fdb4d7fe5d0 100644 --- a/stubs/pyinstaller/PyInstaller/compat.pyi +++ b/stubs/pyinstaller/PyInstaller/compat.pyi @@ -28,9 +28,9 @@ is_openbsd: bool is_hpux: bool is_unix: bool is_musl: bool -is_macos_11_compat: tuple[int, ...] | bool | None -is_macos_11_native: tuple[int, ...] | bool | None -is_macos_11: tuple[int, ...] | bool | None +is_macos_11_compat: bool +is_macos_11_native: bool +is_macos_11: bool PYDYLIB_NAMES: set[str] base_prefix: str is_venv: bool diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi index 9637a91320f3..b519e5d0b240 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi @@ -22,7 +22,7 @@ def exec_statement_rc(statement: str) -> str | int: ... def exec_script(script_filename: StrOrBytesPath, *args: str, env: _Environ | None = ...) -> str | int: ... def exec_script_rc(script_filename: StrOrBytesPath, *args: str, env: _Environ | None = ...) -> str | int: ... def eval_statement(statement: str) -> Any | Literal[""]: ... -def eval_script(scriptfilename: StrOrBytesPath, *args: str, env: _Environ | None = ...) -> Any | Literal[""]: ... +def eval_script(script_filename: StrOrBytesPath, *args: str, env: _Environ | None = ...) -> Any | Literal[""]: ... def get_pyextension_imports(module_name: str) -> list[str]: ... def get_homebrew_path(formula: str = ...) -> str | None: ... def remove_prefix(string: str, prefix: str) -> str: ... @@ -71,3 +71,8 @@ def collect_all( ) -> 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 = ..., +) -> bool: ... From 082ddf21c47adbdbe22a2914af4dcf6c0a349f10 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 15 Sep 2022 08:05:21 -0400 Subject: [PATCH 15/18] Literals, equality, and ignore_missing_stub --- .../pyinstaller/@tests/stubtest_allowlist.txt | 38 ++++++++++++++++++- stubs/pyinstaller/METADATA.toml | 4 +- .../PyInstaller/depend/analysis.pyi | 3 +- .../PyInstaller/depend/imphookapi.pyi | 28 ++++++-------- .../lib/modulegraph/modulegraph.pyi | 24 ++++++------ .../PyInstaller/utils/hooks/__init__.pyi | 5 +-- 6 files changed, 64 insertions(+), 38 deletions(-) diff --git a/stubs/pyinstaller/@tests/stubtest_allowlist.txt b/stubs/pyinstaller/@tests/stubtest_allowlist.txt index 5217cbc762c3..0c41373b7fd3 100644 --- a/stubs/pyinstaller/@tests/stubtest_allowlist.txt +++ b/stubs/pyinstaller/@tests/stubtest_allowlist.txt @@ -1,4 +1,38 @@ # fake module, only exists once the app is frozen pyi_splash -# kwargs -PyInstaller.depend.analysis.PyiModuleGraph.__init__ +# Undocumented and clearly not meant to be exposed +PyInstaller.__main__.generate_parser +PyInstaller.__main__.run_build +PyInstaller.__main__.run_makespec +PyInstaller.utils.hooks.conda.lib_dir +# A mix of modules meant to be private, and shallow incomplete type references for other modules +PyInstaller.building.* +PyInstaller.depend.analysis.* +PyInstaller.isolated._parent.* +# Most modules are not meant to be used, yet are not marked as private +PyInstaller.archive.* +PyInstaller.config +PyInstaller.configure +PyInstaller.depend.bindepend +PyInstaller.depend.bytecode +PyInstaller.depend.dylib +PyInstaller.depend.imphook +PyInstaller.depend.utils +PyInstaller.exceptions +PyInstaller.hooks.* +PyInstaller.lib.* +PyInstaller.loader.* +PyInstaller.log +PyInstaller.utils.cliutils.* +PyInstaller.utils.conftest +PyInstaller.utils.git +PyInstaller.utils.hooks.django +PyInstaller.utils.hooks.gi +PyInstaller.utils.hooks.qt +PyInstaller.utils.hooks.subproc.* +PyInstaller.utils.hooks.tcl_tk +PyInstaller.utils.misc +PyInstaller.utils.osx +PyInstaller.utils.run_tests +PyInstaller.utils.tests +PyInstaller.utils.win32.* diff --git a/stubs/pyinstaller/METADATA.toml b/stubs/pyinstaller/METADATA.toml index 569772c9fbd0..bbed84a0b636 100644 --- a/stubs/pyinstaller/METADATA.toml +++ b/stubs/pyinstaller/METADATA.toml @@ -2,6 +2,4 @@ version = "5.4.*" requires = ["types-setuptools"] [tool.stubtest] -# Most modules are not meant to be used, yet are not marked as private -# Otherwise results in 129 "failed to find stubs" and 106 "is not present in stub" -ignore_missing_stub = true +ignore_missing_stub = false diff --git a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi index bcfd30ee929f..2ae95b655fa0 100644 --- a/stubs/pyinstaller/PyInstaller/depend/analysis.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/analysis.pyi @@ -3,12 +3,11 @@ # The documentation explicitely mentions that "Normally you do not need to know about the module-graph." # However, some PyiModuleGraph typed class attributes are still documented as existing in imphookapi. from _typeshed import Incomplete -from typing_extensions import LiteralString class PyiModuleGraph: # incomplete def __init__( self, - pyi_homepath: LiteralString, + pyi_homepath: str, user_hook_dirs=..., excludes=..., path: Incomplete | None = ..., diff --git a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi index d216820532cd..268ee3618eeb 100644 --- a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi @@ -5,7 +5,7 @@ from _typeshed import StrOrBytesPath from collections.abc import Generator, Iterable from typing import Any -from typing_extensions import Literal, LiteralString +from typing_extensions import Literal from PyInstaller.building.build_main import Analysis from PyInstaller.building.datastruct import TOC @@ -14,14 +14,10 @@ from PyInstaller.lib.modulegraph.modulegraph import Package # https://pyinstaller.org/en/stable/hooks.html#the-pre-safe-import-module-psim-api-method class PreSafeImportModuleAPI: - module_basename: LiteralString - module_name: LiteralString + module_basename: str + module_name: str def __init__( - self, - module_graph: PyiModuleGraph, - module_basename: LiteralString, - module_name: LiteralString, - parent_package: Package | None, + self, module_graph: PyiModuleGraph, module_basename: str, module_name: str, parent_package: Package | None ) -> None: ... @property def module_graph(self) -> PyiModuleGraph: ... @@ -35,32 +31,30 @@ class PreSafeImportModuleAPI: # https://pyinstaller.org/en/stable/hooks.html#the-pre-find-module-path-pfmp-api-method class PreFindModulePathAPI: search_dirs: Iterable[StrOrBytesPath] - def __init__( - self, module_graph: PyiModuleGraph, module_name: LiteralString, search_dirs: Iterable[StrOrBytesPath] - ) -> None: ... + def __init__(self, module_graph: PyiModuleGraph, module_name: str, search_dirs: Iterable[StrOrBytesPath]) -> None: ... @property def module_graph(self) -> PyiModuleGraph: ... @property - def module_name(self) -> LiteralString: ... + def module_name(self) -> str: ... # https://pyinstaller.org/en/stable/hooks.html#the-hook-hook-api-function class PostGraphAPI: module_graph: PyiModuleGraph module: Package - def __init__(self, module_name: LiteralString, module_graph: PyiModuleGraph, analysis: Analysis) -> None: ... + def __init__(self, module_name: str, module_graph: PyiModuleGraph, analysis: Analysis) -> None: ... @property - def __file__(self) -> LiteralString: ... + def __file__(self) -> str: ... @property - def __path__(self) -> tuple[LiteralString, ...] | None: ... + def __path__(self) -> tuple[str, ...] | None: ... @property - def __name__(self) -> LiteralString: ... + def __name__(self) -> str: ... # Compiled code. See stdlib.builtins.compile @property def co(self) -> Any: ... @property def analysis(self) -> Analysis: ... @property - def name(self) -> LiteralString: ... + def name(self) -> str: ... @property def graph(self) -> PyiModuleGraph: ... @property diff --git a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi index f32b9b5698ed..b66ee44fd6fa 100644 --- a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi +++ b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi @@ -1,5 +1,5 @@ from typing import Any, Protocol -from typing_extensions import LiteralString + class _SupportsGraphident(Protocol): graphident: str @@ -10,11 +10,11 @@ class _SupportsGraphident(Protocol): class Node: # Compiled code. See stdlib.builtins.compile code: Any | None - filename: LiteralString | None - graphident: LiteralString - identifier: LiteralString - packagepath: LiteralString | None - def __init__(self, identifier: LiteralString) -> None: ... + filename: str | None + graphident: str + identifier: str + packagepath: str | None + def __init__(self, identifier: str) -> None: ... def is_global_attr(self, attr_name: str) -> bool: ... def is_submodule(self, submodule_basename: str) -> bool: ... def add_global_attr(self, attr_name: str) -> None: ... @@ -23,17 +23,19 @@ class Node: def get_submodule(self, submodule_basename: str) -> Node: ... def get_submodule_or_none(self, submodule_basename: str) -> Node | None: ... def remove_global_attr_if_found(self, attr_name: str) -> None: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... def __lt__(self, other: _SupportsGraphident) -> bool: ... def __le__(self, other: _SupportsGraphident) -> bool: ... def __gt__(self, other: _SupportsGraphident) -> bool: ... def __ge__(self, other: _SupportsGraphident) -> bool: ... - def infoTuple(self) -> tuple[LiteralString]: ... + def infoTuple(self) -> tuple[str]: ... class BaseModule(Node): - filename: LiteralString - packagepath: LiteralString - def __init__(self, name: LiteralString, filename: LiteralString | None = ..., path: LiteralString | None = ...) -> None: ... + filename: str + packagepath: str + def __init__(self, name: str, filename: str | None = ..., path: str | None = ...) -> None: ... # Returns a tuple of length 0, 1, 2, or 3 - def infoTuple(self) -> tuple[LiteralString, ...]: ... # type: ignore[override] + def infoTuple(self) -> tuple[str, ...]: ... # type: ignore[override] class Package(BaseModule): ... diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi index b519e5d0b240..d9324f92975d 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/__init__.pyi @@ -1,8 +1,7 @@ # https://pyinstaller.org/en/stable/hooks.html -import os from _typeshed import StrOrBytesPath, SupportsKeysAndGetItem -from collections.abc import Callable, Iterable +from collections.abc import Callable, Iterable, Mapping from typing import Any from typing_extensions import Literal, TypeAlias @@ -12,7 +11,7 @@ from PyInstaller.depend.imphookapi import PostGraphAPI from PyInstaller.utils.hooks import conda as conda_support from PyInstaller.utils.hooks.win32 import get_pywin32_module_file_attribute as get_pywin32_module_file_attribute -_Environ: TypeAlias = SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] | os._Environ[str] +_Environ: TypeAlias = SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] | Mapping[str, str] PY_IGNORE_EXTENSIONS: set[str] hook_variables: dict[str, str] From d05c59c7320104d7b22e68346b1b8e12ce55e64d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Sep 2022 12:06:41 +0000 Subject: [PATCH 16/18] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi index b66ee44fd6fa..0bbb6ee131b3 100644 --- a/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi +++ b/stubs/pyinstaller/PyInstaller/lib/modulegraph/modulegraph.pyi @@ -1,6 +1,5 @@ from typing import Any, Protocol - class _SupportsGraphident(Protocol): graphident: str From 307e049aec57997a22ad628aeadfd272e9a1621d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 15 Sep 2022 13:14:56 +0100 Subject: [PATCH 17/18] Allow --- stubs/pyinstaller/@tests/stubtest_allowlist.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stubs/pyinstaller/@tests/stubtest_allowlist.txt b/stubs/pyinstaller/@tests/stubtest_allowlist.txt index 0c41373b7fd3..4a11d1f8c69d 100644 --- a/stubs/pyinstaller/@tests/stubtest_allowlist.txt +++ b/stubs/pyinstaller/@tests/stubtest_allowlist.txt @@ -36,3 +36,7 @@ PyInstaller.utils.osx PyInstaller.utils.run_tests PyInstaller.utils.tests PyInstaller.utils.win32.* +# Explicitly private implementation details +PyInstaller\._* +PyInstaller.isolated._child +PyInstaller.utils._git_revision From 0e9f8387cd7d837b73cc0c089ffc75b741ae97ee Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 15 Sep 2022 13:17:27 +0100 Subject: [PATCH 18/18] . --- stubs/pyinstaller/@tests/stubtest_allowlist.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/pyinstaller/@tests/stubtest_allowlist.txt b/stubs/pyinstaller/@tests/stubtest_allowlist.txt index 4a11d1f8c69d..c9c278ea1a3c 100644 --- a/stubs/pyinstaller/@tests/stubtest_allowlist.txt +++ b/stubs/pyinstaller/@tests/stubtest_allowlist.txt @@ -37,6 +37,6 @@ PyInstaller.utils.run_tests PyInstaller.utils.tests PyInstaller.utils.win32.* # Explicitly private implementation details -PyInstaller\._* +PyInstaller\._.* PyInstaller.isolated._child -PyInstaller.utils._git_revision +PyInstaller.utils._gitrevision