Resources: Add return typing suggestion

This commit is contained in:
Mykola Grymalyuk
2023-03-17 20:04:46 -06:00
parent fd2f58da84
commit 0135d6cccf
15 changed files with 140 additions and 112 deletions

View File

@@ -28,7 +28,7 @@ class AmfiConfigurationDetection:
"""
def __init__(self):
def __init__(self) -> None:
self.AMFI_ALLOW_TASK_FOR_PID: bool = False
self.AMFI_ALLOW_INVALID_SIGNATURE: bool = False
self.AMFI_LV_ENFORCE_THIRD_PARTY: bool = False
@@ -45,7 +45,7 @@ class AmfiConfigurationDetection:
self._parse_oclp_configuration()
def _init_nvram_dicts(self):
def _init_nvram_dicts(self) -> None:
"""
Initialize the boot-args and OCLP-Settings NVRAM dictionaries
"""
@@ -60,7 +60,7 @@ class AmfiConfigurationDetection:
self.oclp_args = oclp_args.split(" ")
def _parse_amfi_bitmask(self):
def _parse_amfi_bitmask(self) -> None:
"""
Parse the AMFI bitmask from boot-args
See data/amfi_data.py for more information
@@ -96,7 +96,7 @@ class AmfiConfigurationDetection:
self.AMFI_ALLOW_INVALID_SIGNATURE = True
def _parse_amfi_boot_args(self):
def _parse_amfi_boot_args(self) -> None:
"""
Parse the AMFI boot-args
"""
@@ -121,7 +121,7 @@ class AmfiConfigurationDetection:
self.AMFI_ALLOW_INVALID_SIGNATURE = True
def _parse_oclp_configuration(self):
def _parse_oclp_configuration(self) -> None:
"""
Parse the OCLP configuration
"""
@@ -130,7 +130,7 @@ class AmfiConfigurationDetection:
self.SKIP_LIBRARY_VALIDATION = True
def check_config(self, level: int):
def check_config(self, level: int) -> bool:
"""
Check the AMFI configuration based on provided AMFI level
See AmfiConfigLevel enum for valid levels

View File

@@ -12,7 +12,7 @@ from data import model_array
# Generic building args
class arguments:
def __init__(self, global_constants: constants.Constants):
def __init__(self, global_constants: constants.Constants) -> None:
self.constants: constants.Constants = global_constants
self.args = utilities.check_cli_args()
@@ -20,7 +20,7 @@ class arguments:
self._parse_arguments()
def _parse_arguments(self):
def _parse_arguments(self) -> None:
"""
Parses arguments passed to the patcher
"""
@@ -46,7 +46,7 @@ class arguments:
return
def _validation_handler(self):
def _validation_handler(self) -> None:
"""
Enter validation mode
"""
@@ -54,7 +54,7 @@ class arguments:
validation.PatcherValidation(self.constants)
def _sys_patch_handler(self):
def _sys_patch_handler(self) -> None:
"""
Start root volume patching
"""
@@ -71,7 +71,7 @@ class arguments:
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, None).start_patch()
def _sys_unpatch_handler(self):
def _sys_unpatch_handler(self) -> None:
"""
Start root volume unpatching
"""
@@ -79,7 +79,7 @@ class arguments:
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, None).start_unpatch()
def _sys_patch_auto_handler(self):
def _sys_patch_auto_handler(self) -> None:
"""
Start root volume auto patching
"""
@@ -88,7 +88,7 @@ class arguments:
sys_patch_auto.AutomaticSysPatch(self.constants).start_auto_patch()
def _build_handler(self):
def _build_handler(self) -> None:
"""
Start config building process
"""

View File

@@ -5,7 +5,7 @@ import plistlib
class ParseCommitInfo:
def __init__(self, binary_path: str):
def __init__(self, binary_path: str) -> None:
"""
Parameters:
binary_path (str): Path to binary
@@ -15,7 +15,7 @@ class ParseCommitInfo:
self.plist_path = self._convert_binary_path_to_plist_path()
def _convert_binary_path_to_plist_path(self):
def _convert_binary_path_to_plist_path(self) -> str or None:
"""
Resolve Info.plist path from binary path
"""
@@ -27,7 +27,7 @@ class ParseCommitInfo:
return None
def generate_commit_info(self):
def generate_commit_info(self) -> tuple:
"""
Generate commit info from Info.plist

View File

@@ -10,7 +10,7 @@ from data import os_data
class Constants:
def __init__(self):
def __init__(self) -> None:
# Patcher Versioning
self.patcher_version: str = "0.6.2" # OpenCore-Legacy-Patcher
self.patcher_support_pkg_version: str = "0.8.5" # PatcherSupportPkg

View File

@@ -17,7 +17,7 @@ from data import (
class GenerateDefaults:
def __init__(self, model: str, host_is_target: bool, global_constants: constants.Constants):
def __init__(self, model: str, host_is_target: bool, global_constants: constants.Constants) -> None:
self.constants: constants.Constants = global_constants
self.model: str = model
@@ -51,7 +51,7 @@ class GenerateDefaults:
self._smbios_probe()
def _general_probe(self):
def _general_probe(self) -> None:
"""
General probe for data
"""
@@ -93,7 +93,7 @@ class GenerateDefaults:
self.constants.should_nuke_kdks = False
def _smbios_probe(self):
def _smbios_probe(self) -> None:
"""
SMBIOS specific probe
"""
@@ -128,7 +128,7 @@ class GenerateDefaults:
self.constants.force_vmm = False
def _nvram_probe(self):
def _nvram_probe(self) -> None:
"""
NVRAM specific probe
"""
@@ -153,7 +153,7 @@ class GenerateDefaults:
self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0]
def _networking_probe(self):
def _networking_probe(self) -> None:
"""
Networking specific probe
"""
@@ -195,7 +195,7 @@ class GenerateDefaults:
self.constants.fu_arguments = " -disable_sidecar_mac"
def _misc_hardwares_probe(self):
def _misc_hardwares_probe(self) -> None:
"""
Misc probe
"""
@@ -211,7 +211,7 @@ class GenerateDefaults:
break
def _gpu_probe(self):
def _gpu_probe(self) -> None:
"""
Graphics specific probe
"""

View File

@@ -15,7 +15,7 @@ class GlobalEnviromentSettings:
Library for querying and writing global enviroment settings
"""
def __init__(self):
def __init__(self) -> None:
self.file_name: str = ".com.dortania.opencore-legacy-patcher.plist"
self.global_settings_folder: str = "/Users/Shared"
self.global_settings_plist: str = f"{self.global_settings_folder}/{self.file_name}"
@@ -25,7 +25,7 @@ class GlobalEnviromentSettings:
self._fix_file_permission()
def read_property(self, property_name: str):
def read_property(self, property_name: str) -> str or None:
"""
Reads a property from the global settings file
"""
@@ -37,7 +37,7 @@ class GlobalEnviromentSettings:
return None
def write_property(self, property_name: str, property_value):
def write_property(self, property_name: str, property_value) -> None:
"""
Writes a property to the global settings file
"""
@@ -51,7 +51,7 @@ class GlobalEnviromentSettings:
logging.info("- Failed to write to global settings file")
def _generate_settings_file(self):
def _generate_settings_file(self) -> None:
if Path(self.global_settings_plist).exists():
return
try:
@@ -60,7 +60,7 @@ class GlobalEnviromentSettings:
logging.info("- Permission error: Unable to write to global settings file")
def _convert_defaults_to_global_settings(self):
def _convert_defaults_to_global_settings(self) -> None:
"""
Converts legacy defaults to global settings
"""
@@ -86,7 +86,7 @@ class GlobalEnviromentSettings:
logging.info("- Permission error: Unable to delete defaults plist")
def _fix_file_permission(self):
def _fix_file_permission(self) -> None:
"""
Fixes file permission for log file

View File

@@ -49,7 +49,7 @@ class KernelDebugKitObject:
"""
def __init__(self, global_constants: constants.Constants, host_build: str, host_version: str, ignore_installed: bool = False, passive: bool = False):
def __init__(self, global_constants: constants.Constants, host_build: str, host_version: str, ignore_installed: bool = False, passive: bool = False) -> None:
self.constants: constants.Constants = global_constants
self.host_build: str = host_build # ex. 20A5384c
@@ -83,7 +83,7 @@ class KernelDebugKitObject:
self._get_latest_kdk()
def _get_remote_kdks(self):
def _get_remote_kdks(self) -> list or None:
"""
Fetches a list of available KDKs from the KdkSupportPkg API
Additionally caches the list for future use, avoiding extra API calls
@@ -119,7 +119,7 @@ class KernelDebugKitObject:
return KDK_ASSET_LIST
def _get_latest_kdk(self, host_build: str = None, host_version: str = None):
def _get_latest_kdk(self, host_build: str = None, host_version: str = None) -> None:
"""
Fetches the latest KDK for the current macOS version
@@ -229,7 +229,7 @@ class KernelDebugKitObject:
self.success = True
def retrieve_download(self, override_path: str = ""):
def retrieve_download(self, override_path: str = "") -> network_handler.DownloadObject or None:
"""
Returns a DownloadObject for the KDK
@@ -263,7 +263,7 @@ class KernelDebugKitObject:
return network_handler.DownloadObject(self.kdk_url, kdk_download_path)
def _generate_kdk_info_plist(self, plist_path: str):
def _generate_kdk_info_plist(self, plist_path: str) -> None:
"""
Generates a KDK Info.plist
@@ -285,7 +285,7 @@ class KernelDebugKitObject:
logging.error(f"- Failed to generate KDK Info.plist: {e}")
def _local_kdk_valid(self, kdk_path: Path):
def _local_kdk_valid(self, kdk_path: Path) -> bool:
"""
Validates provided KDK, ensure no corruption
@@ -334,7 +334,7 @@ class KernelDebugKitObject:
return True
def _local_kdk_valid_legacy(self, kdk_path: Path):
def _local_kdk_valid_legacy(self, kdk_path: Path) -> bool:
"""
Legacy variant of validating provided KDK
Uses best guess of files that should be present
@@ -363,7 +363,7 @@ class KernelDebugKitObject:
return True
def _local_kdk_installed(self, match: str = None, check_version: bool = False):
def _local_kdk_installed(self, match: str = None, check_version: bool = False) -> str or None:
"""
Checks if KDK matching build is installed
If so, validates it has not been corrupted
@@ -429,7 +429,7 @@ class KernelDebugKitObject:
return None
def _remove_kdk(self, kdk_path: str):
def _remove_kdk(self, kdk_path: str) -> None:
"""
Removes provided KDK
@@ -460,7 +460,7 @@ class KernelDebugKitObject:
logging.info(f"- Successfully removed KDK: {kdk_path}")
def _remove_unused_kdks(self, exclude_builds: list = None):
def _remove_unused_kdks(self, exclude_builds: list = None) -> None:
"""
Removes KDKs that are not in use
@@ -500,7 +500,7 @@ class KernelDebugKitObject:
self._remove_kdk(kdk_folder)
def validate_kdk_checksum(self, kdk_dmg_path: str = None):
def validate_kdk_checksum(self, kdk_dmg_path: str = None) -> bool:
"""
Validates KDK DMG checksum
@@ -542,11 +542,11 @@ class KernelDebugKitUtilities:
"""
def __init__(self):
def __init__(self) -> None:
pass
def install_kdk_pkg(self, kdk_path: Path):
def install_kdk_pkg(self, kdk_path: Path) -> bool:
"""
Installs provided KDK packages
@@ -577,7 +577,7 @@ class KernelDebugKitUtilities:
return True
def install_kdk_dmg(self, kdk_path: Path):
def install_kdk_dmg(self, kdk_path: Path) -> bool:
"""
Installs provided KDK disk image
@@ -617,7 +617,7 @@ class KernelDebugKitUtilities:
logging.info("- Successfully installed KDK")
return True
def _unmount_disk_image(self, mount_point):
def _unmount_disk_image(self, mount_point) -> None:
"""
Unmounts provided disk image silently
@@ -627,7 +627,7 @@ class KernelDebugKitUtilities:
subprocess.run(["hdiutil", "detach", mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def _create_backup(self, kdk_path: Path, kdk_info_plist: Path):
def _create_backup(self, kdk_path: Path, kdk_info_plist: Path) -> None:
"""
Creates a backup of the KDK

View File

@@ -26,7 +26,7 @@ class InitializeLoggingSupport:
"""
def __init__(self):
def __init__(self) -> None:
self.log_filename: str = "OpenCore-Patcher.log"
self.log_filepath: Path = None
@@ -43,11 +43,11 @@ class InitializeLoggingSupport:
self._fix_file_permission()
def __del__(self):
def __del__(self) -> None:
self._restore_original_excepthook()
def _initialize_logging_path(self):
def _initialize_logging_path(self) -> None:
"""
Initialize logging framework storage path
"""
@@ -62,7 +62,7 @@ class InitializeLoggingSupport:
print(f" - Log file: {self.log_filepath}")
def _clean_log_file(self):
def _clean_log_file(self) -> None:
"""
Determine if log file should be cleaned
@@ -87,7 +87,7 @@ class InitializeLoggingSupport:
print(f"- Failed to clean log file: {e}")
def _fix_file_permission(self):
def _fix_file_permission(self) -> None:
"""
Fixes file permission for log file
@@ -105,7 +105,7 @@ class InitializeLoggingSupport:
print(result.stderr.decode("utf-8"))
def _initialize_logging_configuration(self, log_to_file: bool = True):
def _initialize_logging_configuration(self, log_to_file: bool = True) -> None:
"""
Initialize logging framework configuration
@@ -130,7 +130,7 @@ class InitializeLoggingSupport:
logging.getLogger().handlers[1].maxBytes = self.max_file_size
def _attempt_initialize_logging_configuration(self):
def _attempt_initialize_logging_configuration(self) -> None:
"""
Attempt to initialize logging framework configuration
@@ -145,18 +145,18 @@ class InitializeLoggingSupport:
self._initialize_logging_configuration(log_to_file=False)
def _implement_custom_traceback_handler(self):
def _implement_custom_traceback_handler(self) -> None:
"""
Reroute traceback to logging module
"""
def custom_excepthook(type, value, tb):
def custom_excepthook(type, value, tb) -> None:
"""
Reroute traceback in main thread to logging module
"""
logging.error("Uncaught exception in main thread", exc_info=(type, value, tb))
def custom_thread_excepthook(args):
def custom_thread_excepthook(args) -> None:
"""
Reroute traceback in spawned thread to logging module
"""
@@ -166,7 +166,7 @@ class InitializeLoggingSupport:
threading.excepthook = custom_thread_excepthook
def _restore_original_excepthook(self):
def _restore_original_excepthook(self) -> None:
"""
Restore original traceback handlers
"""

View File

@@ -23,13 +23,19 @@ tmp_dir = tempfile.TemporaryDirectory()
class InstallerCreation():
def __init__(self):
def __init__(self) -> None:
pass
def install_macOS_installer(self, download_path: str):
def install_macOS_installer(self, download_path: str) -> bool:
"""
Installs InstallAssistant.pkg
Parameters:
download_path (str): Path to InstallAssistant.pkg
Returns:
bool: True if successful, False otherwise
"""
logging.info("- Extracting macOS installer from InstallAssistant.pkg\n This may take some time")
@@ -52,7 +58,7 @@ class InstallerCreation():
return True
def generate_installer_creation_script(self, tmp_location, installer_path, disk):
def generate_installer_creation_script(self, tmp_location: str, installer_path: str, disk: str) -> bool:
"""
Creates installer.sh to be piped to OCLP-Helper and run as admin
@@ -67,6 +73,9 @@ class InstallerCreation():
tmp_location (str): Path to temporary directory
installer_path (str): Path to InstallAssistant.pkg
disk (str): Disk to install to
Returns:
bool: True if successful, False otherwise
"""
additional_args = ""
@@ -136,7 +145,8 @@ fi
return True
return False
def list_disk_to_format(self):
def list_disk_to_format(self) -> dict:
"""
List applicable disks for macOS installer creation
Only lists disks that are:
@@ -206,7 +216,7 @@ class RemoteInstallerCatalog:
Parses Apple's Software Update catalog and finds all macOS installers.
"""
def __init__(self, seed_override: SeedType = SeedType.PublicRelease):
def __init__(self, seed_override: SeedType = SeedType.PublicRelease) -> None:
self.catalog_url: str = self._construct_catalog_url(seed_override)
@@ -214,12 +224,15 @@ class RemoteInstallerCatalog:
self.available_apps_latest: dict = self._list_newest_installers_only()
def _construct_catalog_url(self, seed_type: SeedType):
def _construct_catalog_url(self, seed_type: SeedType) -> str:
"""
Constructs the catalog URL based on the seed type
Args:
Parameters:
seed_type (SeedType): The seed type to use
Returns:
str: The catalog URL
"""
@@ -237,7 +250,7 @@ class RemoteInstallerCatalog:
return url
def _fetch_catalog(self):
def _fetch_catalog(self) -> dict:
"""
Fetches the catalog from Apple's servers
@@ -257,7 +270,13 @@ class RemoteInstallerCatalog:
return catalog
def _parse_catalog(self):
def _parse_catalog(self) -> dict:
"""
Parses the catalog and returns a dictionary of available installers
Returns:
dict: Dictionary of available installers
"""
available_apps: dict = {}
catalog: dict = self._fetch_catalog()
@@ -358,7 +377,7 @@ class RemoteInstallerCatalog:
return available_apps
def _list_newest_installers_only(self):
def _list_newest_installers_only(self) -> dict:
"""
Returns a dictionary of the newest macOS installers only.
Primarily used to avoid overwhelming the user with a list of
@@ -449,11 +468,11 @@ class LocalInstallerCatalog:
Finds all macOS installers on the local machine.
"""
def __init__(self):
def __init__(self) -> None:
self.available_apps: dict = self._list_local_macOS_installers()
def _list_local_macOS_installers(self):
def _list_local_macOS_installers(self) -> dict:
"""
Searches for macOS installers in /Applications
@@ -537,7 +556,7 @@ class LocalInstallerCatalog:
return application_list
def _parse_sharedsupport_version(self, sharedsupport_path: Path):
def _parse_sharedsupport_version(self, sharedsupport_path: Path) -> tuple:
"""
Determine true version of macOS installer by parsing SharedSupport.dmg
This is required due to Info.plist reporting the application version, not the OS version

View File

@@ -25,7 +25,7 @@ class OpenCoreLegacyPatcher:
Initial entry point for starting OpenCore Legacy Patcher
"""
def __init__(self):
def __init__(self) -> None:
logging_handler.InitializeLoggingSupport()
self.constants: constants.Constants = constants.Constants()
@@ -40,7 +40,7 @@ class OpenCoreLegacyPatcher:
gui_main.wx_python_gui(self.constants).main_menu(None)
def _generate_base_data(self):
def _generate_base_data(self) -> None:
"""
Generate base data required for the patcher to run
"""

View File

@@ -32,14 +32,14 @@ class NetworkUtilities:
Utilities for network related tasks, primarily used for downloading files
"""
def __init__(self, url: str = None):
def __init__(self, url: str = None) -> None:
self.url: str = url
if self.url is None:
self.url = "https://github.com"
def verify_network_connection(self):
def verify_network_connection(self) -> bool:
"""
Verifies that the network is available
@@ -58,8 +58,13 @@ class NetworkUtilities:
):
return False
def validate_link(self):
# Check if link is 404
def validate_link(self) -> bool:
"""
Check for 404 error
Returns:
bool: True if link is valid, False otherwise
"""
try:
response = SESSION.head(self.url, timeout=5, allow_redirects=True)
if response.status_code == 404:
@@ -93,7 +98,7 @@ class DownloadObject:
"""
def __init__(self, url: str, path: str):
def __init__(self, url: str, path: str) -> None:
self.url: str = url
self.status: str = DownloadStatus.INACTIVE
self.error_msg: str = ""
@@ -121,11 +126,11 @@ class DownloadObject:
self._populate_file_size()
def __del__(self):
def __del__(self) -> None:
self.stop()
def download(self, display_progress: bool = False, spawn_thread: bool = True, verify_checksum: bool = False):
def download(self, display_progress: bool = False, spawn_thread: bool = True, verify_checksum: bool = False) -> None:
"""
Download the file
@@ -152,7 +157,8 @@ class DownloadObject:
self.should_checksum = verify_checksum
self._download(display_progress)
def download_simple(self, verify_checksum: bool = False):
def download_simple(self, verify_checksum: bool = False) -> str or bool:
"""
Alternative to download(), mimics utilities.py's old download_file() function
@@ -176,7 +182,7 @@ class DownloadObject:
return self.checksum.hexdigest() if self.checksum else True
def _get_filename(self):
def _get_filename(self) -> str:
"""
Get the filename from the URL
@@ -187,7 +193,7 @@ class DownloadObject:
return Path(self.url).name
def _populate_file_size(self):
def _populate_file_size(self) -> None:
"""
Get the file size of the file to be downloaded
@@ -206,7 +212,7 @@ class DownloadObject:
self.total_file_size = 0.0
def _update_checksum(self, chunk: bytes):
def _update_checksum(self, chunk: bytes) -> None:
"""
Update checksum with new chunk
@@ -216,7 +222,7 @@ class DownloadObject:
self._checksum_storage.update(chunk)
def _prepare_working_directory(self, path: Path):
def _prepare_working_directory(self, path: Path) -> bool:
"""
Validates working enviroment, including free space and removing existing files
@@ -253,7 +259,7 @@ class DownloadObject:
return True
def _download(self, display_progress: bool = False):
def _download(self, display_progress: bool = False) -> None:
"""
Download the file
@@ -306,7 +312,7 @@ class DownloadObject:
utilities.enable_sleep_after_running()
def get_percent(self):
def get_percent(self) -> float:
"""
Query the download percent
@@ -320,7 +326,7 @@ class DownloadObject:
return self.downloaded_file_size / self.total_file_size * 100
def get_speed(self):
def get_speed(self) -> float:
"""
Query the download speed
@@ -331,7 +337,7 @@ class DownloadObject:
return self.downloaded_file_size / (time.time() - self.start_time)
def get_time_remaining(self):
def get_time_remaining(self) -> float:
"""
Query the time remaining for the download
@@ -345,7 +351,7 @@ class DownloadObject:
return (self.total_file_size - self.downloaded_file_size) / self.get_speed()
def get_file_size(self):
def get_file_size(self) -> float:
"""
Query the file size of the file to be downloaded
@@ -356,7 +362,7 @@ class DownloadObject:
return self.total_file_size
def is_active(self):
def is_active(self) -> bool:
"""
Query if the download is active
@@ -369,12 +375,11 @@ class DownloadObject:
return False
def stop(self):
def stop(self) -> None:
"""
Stop the download
Returns:
boolean: If the download is active, this function will hold the thread until stopped
If the download is active, this function will hold the thread until stopped
"""
self.should_stop = True

View File

@@ -10,11 +10,11 @@ class OSProbe:
Library for querying OS information specific to macOS
"""
def __init__(self):
def __init__(self) -> None:
self.uname_data = platform.uname()
def detect_kernel_major(self):
def detect_kernel_major(self) -> int:
"""
Detect the booted major kernel version
@@ -25,7 +25,7 @@ class OSProbe:
return int(self.uname_data.release.partition(".")[0])
def detect_kernel_minor(self):
def detect_kernel_minor(self) -> int:
"""
Detect the booted minor kernel version
@@ -36,7 +36,7 @@ class OSProbe:
return int(self.uname_data.release.partition(".")[2].partition(".")[0])
def detect_os_version(self):
def detect_os_version(self) -> str:
"""
Detect the booted OS version
@@ -51,7 +51,7 @@ class OSProbe:
return result.stdout.decode().strip()
def detect_os_build(self, rsr: bool = False):
def detect_os_build(self, rsr: bool = False) -> str:
"""
Detect the booted OS build

View File

@@ -13,13 +13,13 @@ from resources import constants
class RoutePayloadDiskImage:
def __init__(self, global_constants: constants.Constants):
def __init__(self, global_constants: constants.Constants) -> None:
self.constants: constants.Constants = global_constants
self._setup_tmp_disk_image()
def _setup_tmp_disk_image(self):
def _setup_tmp_disk_image(self) -> None:
"""
Initialize temp directory and mount payloads.dmg
Create overlay for patcher to write to
@@ -55,7 +55,7 @@ class RoutePayloadDiskImage:
logging.info(f"Return Code: {output.returncode}")
def _unmount_active_dmgs(self, unmount_all_active=True):
def _unmount_active_dmgs(self, unmount_all_active=True) -> None:
"""
Unmounts disk images associated with OCLP

View File

@@ -11,14 +11,14 @@ REPO_LATEST_RELEASE_URL: str = "https://api.github.com/repos/dortania/OpenCore-L
class CheckBinaryUpdates:
def __init__(self, global_constants: constants.Constants):
def __init__(self, global_constants: constants.Constants) -> None:
self.constants: constants.Constants = global_constants
self.binary_version = self.constants.patcher_version
self.binary_version_array = [int(x) for x in self.binary_version.split(".")]
def _check_if_build_newer(self, remote_version: list = None, local_version: list = None):
def _check_if_build_newer(self, remote_version: list = None, local_version: list = None) -> bool:
"""
Check if the remote version is newer than the local version
@@ -50,7 +50,7 @@ class CheckBinaryUpdates:
return False
def _determine_local_build_type(self):
def _determine_local_build_type(self) -> str:
"""
Check if the local build is a GUI or TUI build
@@ -64,7 +64,7 @@ class CheckBinaryUpdates:
return "TUI"
def _determine_remote_type(self, remote_name: str):
def _determine_remote_type(self, remote_name: str) -> str:
"""
Check if the remote build is a GUI or TUI build
@@ -83,7 +83,7 @@ class CheckBinaryUpdates:
return "Unknown"
def check_binary_updates(self):
def check_binary_updates(self) -> dict:
"""
Check if any updates are available for the OpenCore Legacy Patcher binary

View File

@@ -15,7 +15,7 @@ class PatcherValidation:
Primarily for Continuous Integration
"""
def __init__(self, global_constants: constants.Constants):
def __init__(self, global_constants: constants.Constants) -> None:
self.constants: constants.Constants = global_constants
self.constants.validate = True
@@ -54,7 +54,7 @@ class PatcherValidation:
self._validate_sys_patch()
def _build_prebuilt(self):
def _build_prebuilt(self) -> None:
"""
Generate a build for each predefined model
Then validate against ocvalidate
@@ -73,7 +73,7 @@ class PatcherValidation:
logging.info(f"Validation succeeded for predefined model: {model}")
def _build_dumps(self):
def _build_dumps(self) -> None:
"""
Generate a build for each predefined model
Then validate against ocvalidate
@@ -93,9 +93,13 @@ class PatcherValidation:
logging.info(f"Validation succeeded for predefined model: {self.constants.computer.real_model}")
def _validate_root_patch_files(self, major_kernel, minor_kernel):
def _validate_root_patch_files(self, major_kernel: int, minor_kernel: int) -> None:
"""
Validate that all files in the patchset are present in the payload
Parameters:
major_kernel (int): Major kernel version
minor_kernel (int): Minor kernel version
"""
patchset = sys_patch_dict.SystemPatchDictionary(major_kernel, minor_kernel, self.constants.legacy_accel_support)
@@ -124,7 +128,7 @@ class PatcherValidation:
Path(self.constants.payload_path / f"OpenCore-Legacy-Patcher-{major_kernel}.{minor_kernel}.plist").unlink()
def _validate_sys_patch(self):
def _validate_sys_patch(self) -> None:
"""
Validates sys_patch modules
"""
@@ -160,7 +164,7 @@ class PatcherValidation:
logging.info("- Skipping Root Patch File integrity validation")
def _validate_configs(self):
def _validate_configs(self) -> None:
"""
Validates build modules
"""