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
+16 -16
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