clan_vm_manager: Fix mypy errors for clan_cli types
This commit is contained in:
parent
7c2e22de72
commit
4e5d051847
@ -116,7 +116,7 @@ class VMObject(GObject.Object):
|
|||||||
@contextmanager
|
@contextmanager
|
||||||
def _create_machine(self) -> Generator[Machine, None, None]:
|
def _create_machine(self) -> Generator[Machine, None, None]:
|
||||||
uri = ClanURI.from_str(
|
uri = ClanURI.from_str(
|
||||||
url=self.data.flake.flake_url, machine_name=self.data.flake.flake_attr
|
url=str(self.data.flake.flake_url), machine_name=self.data.flake.flake_attr
|
||||||
)
|
)
|
||||||
if uri.flake_id.is_local():
|
if uri.flake_id.is_local():
|
||||||
self.machine = Machine(
|
self.machine = Machine(
|
||||||
@ -128,6 +128,7 @@ class VMObject(GObject.Object):
|
|||||||
name=self.data.flake.flake_attr,
|
name=self.data.flake.flake_attr,
|
||||||
flake=uri.flake_id.url,
|
flake=uri.flake_id.url,
|
||||||
)
|
)
|
||||||
|
assert self.machine is not None
|
||||||
yield self.machine
|
yield self.machine
|
||||||
self.machine = None
|
self.machine = None
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ class JoinList:
|
|||||||
def _on_join_finished(self, source: JoinValue) -> None:
|
def _on_join_finished(self, source: JoinValue) -> None:
|
||||||
log.info(f"Join finished: {source.url}")
|
log.info(f"Join finished: {source.url}")
|
||||||
self.discard(source)
|
self.discard(source)
|
||||||
|
assert source.entry is not None
|
||||||
ClanStore.use().push_history_entry(source.entry)
|
ClanStore.use().push_history_entry(source.entry)
|
||||||
|
|
||||||
def discard(self, value: JoinValue) -> None:
|
def discard(self, value: JoinValue) -> None:
|
||||||
|
@ -73,18 +73,18 @@ class ClanStore:
|
|||||||
def push_history_entry(self, entry: HistoryEntry) -> None:
|
def push_history_entry(self, entry: HistoryEntry) -> None:
|
||||||
# TODO: We shouldn't do this here but in the list view
|
# TODO: We shouldn't do this here but in the list view
|
||||||
if entry.flake.icon is None:
|
if entry.flake.icon is None:
|
||||||
icon = assets.loc / "placeholder.jpeg"
|
icon: Path = assets.loc / "placeholder.jpeg"
|
||||||
else:
|
else:
|
||||||
icon = entry.flake.icon
|
icon = Path(entry.flake.icon)
|
||||||
|
|
||||||
vm = VMObject(
|
vm = VMObject(
|
||||||
icon=Path(icon),
|
icon=icon,
|
||||||
data=entry,
|
data=entry,
|
||||||
)
|
)
|
||||||
self.push(vm)
|
self.push(vm)
|
||||||
|
|
||||||
def push(self, vm: VMObject) -> None:
|
def push(self, vm: VMObject) -> None:
|
||||||
url = vm.data.flake.flake_url
|
url = str(vm.data.flake.flake_url)
|
||||||
|
|
||||||
# Only write to the store if the Clan is not already in it
|
# Only write to the store if the Clan is not already in it
|
||||||
# Every write to the KVStore rerenders bound widgets to the clan_store
|
# Every write to the KVStore rerenders bound widgets to the clan_store
|
||||||
@ -108,7 +108,7 @@ class ClanStore:
|
|||||||
vm_store.append(vm)
|
vm_store.append(vm)
|
||||||
|
|
||||||
def remove(self, vm: VMObject) -> None:
|
def remove(self, vm: VMObject) -> None:
|
||||||
del self.clan_store[vm.data.flake.flake_url][vm.data.flake.flake_attr]
|
del self.clan_store[str(vm.data.flake.flake_url)][vm.data.flake.flake_attr]
|
||||||
|
|
||||||
def get_vm(self, uri: ClanURI) -> None | VMObject:
|
def get_vm(self, uri: ClanURI) -> None | VMObject:
|
||||||
vm_store = self.clan_store.get(str(uri.flake_id))
|
vm_store = self.clan_store.get(str(uri.flake_id))
|
||||||
|
Loading…
Reference in New Issue
Block a user