fixed type errors when pylance type checking mode is strict.

This commit is contained in:
2023-07-19 21:47:47 +09:00
parent 23025bd679
commit 08d8a0626a
24 changed files with 387 additions and 236 deletions

View File

@ -1,4 +1,5 @@
from argparse import Namespace, _SubParsersAction
from argparse import Namespace
from typing import Any
from mdrsclient.api import LaboratoryApi
from mdrsclient.commands.base import BaseCommand
@ -6,15 +7,20 @@ from mdrsclient.commands.base import BaseCommand
class LabsCommand(BaseCommand):
@classmethod
def register(cls, parsers: _SubParsersAction) -> None:
command = cls()
def register(cls, parsers: Any) -> None:
labs_parser = parsers.add_parser("labs", help="list all laboratories")
labs_parser.add_argument("remote", help="label of remote host")
labs_parser.set_defaults(func=command.labs)
labs_parser.set_defaults(func=cls.func)
def labs(self, args: Namespace) -> None:
remote = self._parse_remote_host(args.remote)
connection = self._create_connection(remote)
@classmethod
def func(cls, args: Namespace) -> None:
remote = str(args.remote)
cls.labs(remote)
@classmethod
def labs(cls, remote: str) -> None:
remote = cls._parse_remote_host(remote)
connection = cls._create_connection(remote)
laboratory_api = LaboratoryApi(connection)
laboratories = laboratory_api.list()
connection.laboratories = laboratories