Merge pull request #1408 from ogayot/ubuntu-pro-mypy

ubuntu-pro: fix type hints for contract selection callbacks
This commit is contained in:
Olivier Gayot 2022-09-12 11:40:16 +02:00 committed by GitHub
commit 3f47c469aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -160,19 +160,19 @@ class UbuntuProController(SubiquityTuiController):
self._check_task.cancel() self._check_task.cancel()
def contract_selection_initiate( def contract_selection_initiate(
self, on_initiated: Callable[[str, str], None]) -> None: self, on_initiated: Callable[[str], None]) -> None:
""" Initiate the contract selection asynchronously. Calls on_initiated """ Initiate the contract selection asynchronously. Calls on_initiated
when the contract-selection has initiated. """ when the contract-selection has initiated. """
async def inner() -> None: async def inner() -> None:
answer = await self.endpoint.contract_selection.initiate.POST() answer = await self.endpoint.contract_selection.initiate.POST()
self.cs_initiated = True self.cs_initiated = True
on_initiated(user_code=answer.user_code) on_initiated(answer.user_code)
self._magic_attach_task = schedule_task(inner()) self._magic_attach_task = schedule_task(inner())
def contract_selection_wait( def contract_selection_wait(
self, self,
on_contract_selected: Callable[[str], None], on_contract_selected: Callable[[str], None],
on_timeout: Callable[[None], None]) -> None: on_timeout: Callable[[], None]) -> None:
""" Asynchronously wait for the contract selection to finish. """ Asynchronously wait for the contract selection to finish.
Calls on_contract_selected with the contract-token once the contract Calls on_contract_selected with the contract-token once the contract
gets selected gets selected
@ -193,7 +193,7 @@ class UbuntuProController(SubiquityTuiController):
self._monitor_task = schedule_task(inner()) self._monitor_task = schedule_task(inner())
def contract_selection_cancel( def contract_selection_cancel(
self, on_cancelled: Callable[[None], None]) -> None: self, on_cancelled: Callable[[], None]) -> None:
""" Cancel the asynchronous contract selection (if started). """ """ Cancel the asynchronous contract selection (if started). """
async def inner() -> None: async def inner() -> None:
await self.endpoint.contract_selection.cancel.POST() await self.endpoint.contract_selection.cancel.POST()