diff --git a/PyInstaller/__main__.py b/PyInstaller/__main__.py index 94a906ce228..b7b66684aa8 100644 --- a/PyInstaller/__main__.py +++ b/PyInstaller/__main__.py @@ -147,7 +147,7 @@ def generate_parser() -> _PyiArgumentParser: return parser -def run(pyi_args: list | None = None, pyi_config: dict | list | None = None): +def run(pyi_args: list | None = None, pyi_config: dict | None = None): """ pyi_args allows running PyInstaller programmatically without a subprocess pyi_config allows checking configuration once when running multiple tests diff --git a/PyInstaller/compat.py b/PyInstaller/compat.py index 3d4096cb3f7..acf59b4ae6b 100644 --- a/PyInstaller/compat.py +++ b/PyInstaller/compat.py @@ -75,7 +75,7 @@ # The same logic applies to macOS 12 (Monterey). is_macos_11_compat = bool(_macos_ver and _macos_ver[0:2] == (10, 16)) # Big Sur or newer in compat mode is_macos_11_native = bool(_macos_ver and _macos_ver[0:2] >= (11, 0)) # Big Sur or newer in native mode -is_macos_11 = bool(is_macos_11_compat or is_macos_11_native) # Big Sur or newer +is_macos_11 = is_macos_11_compat or is_macos_11_native # Big Sur or newer # On different platforms is different file for dynamic python library. # TODO: When removing support for is_py37, the "m" variants can be @@ -216,7 +216,7 @@ # Wine detection and support -def is_wine_dll(filename: str | bytes | os.PathLike | int): +def is_wine_dll(filename: str | os.PathLike | int): """ Check if the given PE file is a Wine DLL (PE-converted built-in, or fake/placeholder one). @@ -283,10 +283,7 @@ def unsetenv(name: str): def exec_command( - *cmdargs: str, - encoding: str | None = None, - raise_enoent: bool | None = None, - **kwargs: int | bool | Iterable | None + *cmdargs: str, encoding: str | None = None, raise_enoent: bool | None = None, **kwargs: int | bool | list | None ): """ Run the command specified by the passed positional arguments, optionally configured by the passed keyword arguments. @@ -564,7 +561,7 @@ def exec_python_rc(*args: str, **kwargs: str | None): # Path handling. -def expand_path(path: str | bytes | os.PathLike): +def expand_path(path: str | os.PathLike): """ Replace initial tilde '~' in path with user's home directory, and also expand environment variables (i.e., ${VARNAME} on Unix, %VARNAME% on Windows). @@ -605,7 +602,7 @@ def getsitepackages(prefixes: list | None = None): # Wrapper to load a module from a Python source file. This function loads import hooks when processing them. -def importlib_load_source(name: str, pathname: bytes | str): +def importlib_load_source(name: str, pathname: str): # Import module from a file. mod_loader = importlib.machinery.SourceFileLoader(name, pathname) return mod_loader.load_module() diff --git a/PyInstaller/utils/hooks/__init__.py b/PyInstaller/utils/hooks/__init__.py index 556df17fffd..19b1184bf2a 100644 --- a/PyInstaller/utils/hooks/__init__.py +++ b/PyInstaller/utils/hooks/__init__.py @@ -127,7 +127,7 @@ def __exec_script(script_filename, *args, env=None, capture_stdout=True): return __exec_python_cmd(cmd, env=env, capture_stdout=capture_stdout) -def exec_script(script_filename: str | bytes | os.PathLike, *args: str, env: dict | list | None = None): +def exec_script(script_filename: str | os.PathLike, *args: str, env: dict | None = None): """ Executes a Python script in an externally spawned interpreter, and returns anything that was emitted to the standard output as a single string. @@ -138,7 +138,7 @@ def exec_script(script_filename: str | bytes | os.PathLike, *args: str, env: dic return __exec_script(script_filename, *args, env=env, capture_stdout=True) -def exec_script_rc(script_filename: str | bytes | os.PathLike, *args: str, env: dict | list | None = None): +def exec_script_rc(script_filename: str | os.PathLike, *args: str, env: dict | None = None): """ Executes a Python script in an externally spawned interpreter, and returns the exit code. @@ -173,7 +173,7 @@ def eval_statement(statement: str): return eval(txt) -def eval_script(script_filename: str | bytes | os.PathLike, *args: str, env: dict | list | None = None): +def eval_script(script_filename: str | os.PathLike, *args: str, env: dict | None = None): txt = exec_script(script_filename, *args, env=env).strip() if not txt: # Return an empty string, which is "not true" but is iterable. @@ -757,7 +757,7 @@ def is_module_or_submodule(name: str, mod_or_submod: str): ] -def collect_dynamic_libs(package: str, destdir: object | None = None): +def collect_dynamic_libs(package: str, destdir: str | None = None): """ This function produces a list of (source, dest) of dynamic library files that reside in package. Its output can be directly assigned to ``binaries`` in a hook script. The package parameter must be a string which names the package. @@ -801,7 +801,7 @@ def collect_dynamic_libs(package: str, destdir: object | None = None): def collect_data_files( package: str, include_py_files: bool = False, - subdir: str | bytes | os.PathLike | None = None, + subdir: str | os.PathLike | None = None, excludes: list | None = None, includes: list | None = None, ): @@ -907,9 +907,7 @@ def clude_walker( return datas -def collect_system_data_files( - path: str, destdir: str | bytes | os.PathLike | None = None, include_py_files: bool = False -): +def collect_system_data_files(path: str, destdir: str | os.PathLike | None = None, include_py_files: bool = False): """ This function produces a list of (source, dest) non-Python (i.e., data) files that reside somewhere on the system. Its output can be directly assigned to ``datas`` in a hook script.