-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Added PyInstaller stubs for all documented modules & packages #8702
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
Changes from 6 commits
3b218bb
2e1546b
a0b204a
3801205
dd58adc
e445bea
28cee78
925152b
9e54a30
7278859
e35ee77
69e18c5
927419e
7019f09
202d857
082ddf2
d05c59c
307e049
0e9f838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# fake module, only exists once the app is frozen | ||
pyi_splash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version = "5.3.*" | ||
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 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class Analysis(Target): | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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 = ..., | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
excludes=..., | ||
runtime_hooks=..., | ||
cipher=..., | ||
win_no_prefer_redirects: bool = ..., | ||
win_private_assemblies: bool = ..., | ||
noarchive: bool = ..., | ||
module_collection_mode=..., | ||
) -> None: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused about why pyright isn't emitting an error here. There's no entry in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a guess: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea -- anyway, it's not your fault, and we certainly don't have a requirement that all parameters need to be annotated when first adding stubs :) I'll look into it and try to work it out... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# https://pyinstaller.org/en/stable/advanced-topics.html#the-toc-and-tree-classes | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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: Sequence[str] | ||
typecode: _TypeCode | ||
def __init__( | ||
self, root: str | None = ..., prefix: str | None = ..., excludes: Sequence[str] | None = ..., typecode: _TypeCode = ... | ||
) -> None: ... | ||
def assemble(self) -> None: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# 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 | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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] | ||
|
||
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: ... | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@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: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from _typeshed import Self | ||
from collections.abc import Callable | ||
from functools import _AnyCallable | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from types import TracebackType | ||
from typing import TypeVar | ||
from typing_extensions import ParamSpec | ||
|
||
_AC = TypeVar("_AC", bound=_AnyCallable) | ||
_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: ... | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# 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 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 | ||
|
||
_Environ: TypeAlias = SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] | os._Environ[str] | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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[""]: ... | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@isolated.decorate | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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]]: ... | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# 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] | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
depends: list[str] | ||
|
||
class Distribution: | ||
raw: _RawDict | ||
name: str | ||
version: str | ||
files: list[PackagePath] | ||
dependencies: list[str] | ||
packages: list[str | None] | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __init__(self, json_path: str) -> None: ... | ||
@classmethod | ||
def from_name(cls, name: str) -> 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: ... | ||
|
||
def walk_dependency_tree(initial: str, excludes: Sequence[str] | None = ...) -> dict[str, Distribution]: ... | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 = ... | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) -> list[tuple[str, str]]: ... | ||
|
||
distributions: dict[str, Distribution] | ||
distributions_by_package: dict[str | None, Distribution] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__all__ = ("get_pywin32_module_file_attribute",) | ||
|
||
def get_pywin32_module_file_attribute(module_name: str) -> str | int: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.