Cast result to list after _updateLocalPackages

Because the _updateLocalPackages function guarantees it to be a list now, not None any more.

Contributes to issue CURA-8587.
This commit is contained in:
Ghostkeeper 2021-12-06 17:14:02 +01:00
parent f932239b6a
commit e525770332
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,7 +1,7 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from typing import Any, Dict, List, Tuple, TYPE_CHECKING, Optional, Generator from typing import Any, cast, Dict, List, Tuple, TYPE_CHECKING, Optional, Generator
from cura.CuraApplication import CuraApplication #To find some resource types. from cura.CuraApplication import CuraApplication #To find some resource types.
from cura.Settings.GlobalStack import GlobalStack from cura.Settings.GlobalStack import GlobalStack
@ -30,7 +30,9 @@ class CuraPackageManager(PackageManager):
"""locally installed packages, lazy execution""" """locally installed packages, lazy execution"""
if self._local_packages is None: if self._local_packages is None:
self._updateLocalPackages() self._updateLocalPackages()
return self._local_packages # _updateLocalPackages always results in a list of packages, not None.
# It's guaranteed to be a list now.
return cast(List[Dict[str, Any]], self._local_packages)
def initialize(self) -> None: def initialize(self) -> None:
self._installation_dirs_dict["materials"] = Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer) self._installation_dirs_dict["materials"] = Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer)