Fix Constants type suggestion

This commit is contained in:
Mykola Grymalyuk
2023-02-09 17:59:53 -07:00
parent 66a5f5a9ad
commit e83e260db7
12 changed files with 39 additions and 29 deletions

View File

@@ -11,8 +11,9 @@ from data import model_array
# Generic building args
class arguments:
def __init__(self, global_constants: constants.Constants()):
self.constants: constants.Constants() = global_constants
def __init__(self, global_constants: constants.Constants):
self.constants: constants.Constants = global_constants
self.args = utilities.check_cli_args()

View File

@@ -17,8 +17,8 @@ from data import (
class GenerateDefaults:
def __init__(self, model: str, host_is_target: bool, global_constants: constants.Constants()):
self.constants: constants.Constants() = global_constants
def __init__(self, model: str, host_is_target: bool, global_constants: constants.Constants):
self.constants: constants.Constants = global_constants
self.model = model
self.host_is_target = host_is_target

View File

@@ -12,15 +12,16 @@ import subprocess
class global_settings:
def __init__(self):
self.file_name = ".com.dortania.opencore-legacy-patcher.plist"
self.global_settings_folder = "/Users/Shared"
self.global_settings_plist = f"{self.global_settings_folder}/{self.file_name}"
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}"
self._generate_settings_file()
self._convert_defaults_to_global_settings()
self._fix_file_permission()
def read_property(self, property_name):
def read_property(self, property_name: str):
"""
Reads a property from the global settings file
"""
@@ -32,7 +33,7 @@ class global_settings:
return None
def write_property(self, property_name, property_value):
def write_property(self, property_name: str, property_value):
"""
Writes a property to the global settings file
"""

View File

@@ -15,8 +15,7 @@ import os
import logging
from resources import utilities, network_handler
from resources.constants import Constants
from resources import utilities, network_handler, constants
from data import os_data
KDK_INSTALL_PATH: str = "/Library/Developer/KDKs"
@@ -50,8 +49,8 @@ class KernelDebugKitObject:
"""
def __init__(self, constants: Constants, host_build: str, host_version: str, ignore_installed: bool = False, passive: bool = False):
self.constants: Constants = constants
def __init__(self, global_constants: constants.Constants, host_build: str, host_version: str, ignore_installed: bool = False, passive: bool = False):
self.constants: constants.Constants = global_constants
self.host_build: str = host_build # ex. 20A5384c
self.host_version: str = host_version # ex. 11.0.1

View File

@@ -28,7 +28,7 @@ class OpenCoreLegacyPatcher:
def __init__(self):
logging_handler.InitializeLoggingSupport()
self.constants: constants = constants.Constants()
self.constants: constants.Constants = constants.Constants()
self.constants.wxpython_variant: bool = True

View File

@@ -13,8 +13,8 @@ from resources import constants
class RoutePayloadDiskImage:
def __init__(self, global_constants: constants.Constants()):
self.constants: constants.Constants() = global_constants
def __init__(self, global_constants: constants.Constants):
self.constants: constants.Constants = global_constants
self._setup_tmp_disk_image()

View File

@@ -46,9 +46,9 @@ from data import os_data
class PatchSysVolume:
def __init__(self, model, versions, hardware_details=None):
def __init__(self, model: str, global_constants: constants.Constants, hardware_details: list = None):
self.model = model
self.constants: constants.Constants() = versions
self.constants: constants.Constants = global_constants
self.computer = self.constants.computer
self.root_mount_path = None
self.root_supports_snapshot = utilities.check_if_root_is_apfs_snapshot()
@@ -72,7 +72,15 @@ class PatchSysVolume:
if Path(self.constants.payload_local_binaries_root_path).exists():
shutil.rmtree(self.constants.payload_local_binaries_root_path)
def _init_pathing(self, custom_root_mount_path=None, custom_data_mount_path=None):
def _init_pathing(self, custom_root_mount_path: Path = None, custom_data_mount_path: Path = None):
"""
Initializes the pathing for root volume patching
Parameters:
custom_root_mount_path (Path): Custom path to mount the root volume
custom_data_mount_path (Path): Custom path to mount the data volume
"""
if custom_root_mount_path and custom_data_mount_path:
self.mount_location = custom_root_mount_path
self.data_mount_location = custom_data_mount_path
@@ -83,6 +91,7 @@ class PatchSysVolume:
else:
self.mount_location = ""
self.mount_location_data = ""
self.mount_extensions = f"{self.mount_location}/System/Library/Extensions"
self.mount_application_support = f"{self.mount_location_data}/Library/Application Support"

View File

@@ -19,8 +19,8 @@ from resources.gui import gui_main
class AutomaticSysPatch:
def __init__(self, global_constants: constants.Constants()):
self.constants: constants.Constants() = global_constants
def __init__(self, global_constants: constants.Constants):
self.constants: constants.Constants = global_constants
def start_auto_patch(self):

View File

@@ -27,9 +27,9 @@ from data import (
class detect_root_patch:
def __init__(self, model: str, versions: constants.Constants()):
def __init__(self, model: str, global_constants: constants.Constants):
self.model = model
self.constants: constants.Constants() = versions
self.constants: constants.Constants = global_constants
self.computer = self.constants.computer
# GPU Patch Detection

View File

@@ -14,8 +14,8 @@ from resources import bplist, constants, generate_smbios, utilities
class sys_patch_helpers:
def __init__(self, global_constants: constants.Constants()):
self.constants: constants.Constants() = global_constants
def __init__(self, global_constants: constants.Constants):
self.constants: constants.Constants = global_constants
def snb_board_id_patch(self, source_files_path):

View File

@@ -11,8 +11,8 @@ REPO_LATEST_RELEASE_URL: str = "https://api.github.com/repos/dortania/OpenCore-L
class check_binary_updates:
def __init__(self, global_constants: constants.Constants()):
self.constants: constants.Constants() = global_constants
def __init__(self, global_constants: constants.Constants):
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(".")]

View File

@@ -15,8 +15,8 @@ class PatcherValidation:
Primarily for Continuous Integration
"""
def __init__(self, global_constants: constants.Constants()):
self.constants: constants.Constants() = global_constants
def __init__(self, global_constants: constants.Constants):
self.constants: constants.Constants = global_constants
self.constants.validate = True