Skip to content

Commit

Permalink
Fix some mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidev committed Jan 12, 2025
1 parent 0973ecc commit 686fc43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 4 additions & 8 deletions aqt/commercial.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _get_cache_file(self) -> Path:
"""Get the cache file path."""
return self.cache_dir / "packages.json"

def _save_to_cache(self):
def _save_to_cache(self) -> None:
"""Save packages information to cache."""
cache_data = [{"name": pkg.name, "displayname": pkg.displayname, "version": pkg.version} for pkg in self.packages]

Expand All @@ -66,7 +66,7 @@ def _load_from_cache(self) -> bool:
except (json.JSONDecodeError, KeyError):
return False

def _parse_packages_xml(self, xml_content: str):
def _parse_packages_xml(self, xml_content: str) -> None:
"""Parse packages XML content and extract package information using defusedxml."""
try:
# Use defusedxml.ElementTree to safely parse the XML content
Expand Down Expand Up @@ -222,7 +222,7 @@ def __init__(
self.os_name = CommercialInstaller._get_os_name()
self._installer_filename = CommercialInstaller._get_qt_installer_name()
self.qt_account = CommercialInstaller._get_qt_account_path()
self.package_manager = None
self.package_manager = QtPackageManager(self.arch, self.version, self.target, Settings.qt_installer_cache_path)

@staticmethod
def get_auto_answers() -> str:
Expand Down Expand Up @@ -299,7 +299,6 @@ def install(self) -> None:
installer_path = temp_path / self._installer_filename

self.logger.info(f"Downloading Qt installer to {installer_path}")
installer_url = f"{self.base_url}/official_releases/online_installers/{self._installer_filename}"
self.download_installer(installer_path, Settings.qt_installer_timeout)

try:
Expand All @@ -308,9 +307,6 @@ def install(self) -> None:
cmd = self.build_command(str(installer_path), override=self.override, no_unattended=self.no_unattended)
else:
# Initialize package manager and gather packages
self.package_manager = QtPackageManager(
arch=self.arch, version=self.version, target=self.target, temp_dir=str(cache_path)
)
self.package_manager.gather_packages(str(installer_path))

base_cmd = self.build_command(
Expand Down Expand Up @@ -366,7 +362,7 @@ def _get_qt_account_path() -> Path:
return CommercialInstaller._get_qt_local_folder_path() / "qtaccount.ini"

@staticmethod
def _get_qt_installer_name() -> Path:
def _get_qt_installer_name() -> str:
installer_dict = {
"windows": "qt-unified-windows-x64-online.exe",
"mac": "qt-unified-macOS-x64-online.dmg",
Expand Down
5 changes: 4 additions & 1 deletion tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2078,8 +2078,11 @@ def test_install_qt_commercial(
) -> None:
"""Test commercial Qt installation command"""

def mock_run(*args, **kwargs) -> int:
return 0

# Use monkeypatch to replace subprocess.run
monkeypatch.setattr(subprocess, "run", lambda *args, **kwargs: None)
monkeypatch.setattr(subprocess, "run", mock_run)

current_platform = sys.platform.lower()
arch = arch_dict[current_platform]
Expand Down

0 comments on commit 686fc43

Please sign in to comment.