From: garciadeblas Date: Sat, 8 Feb 2025 10:30:39 +0000 (+0100) Subject: Fix typing issues detected by pylance X-Git-Tag: v18.0.0~34 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F14915%2F2;p=osm%2FLCM.git Fix typing issues detected by pylance Change-Id: Id5dbc01e34e83abccb7dbbaba8edc6f7ec658ddd Signed-off-by: garciadeblas --- diff --git a/osm_lcm/lcm_helm_conn.py b/osm_lcm/lcm_helm_conn.py index d2fa2dfa..d7cd5fad 100644 --- a/osm_lcm/lcm_helm_conn.py +++ b/osm_lcm/lcm_helm_conn.py @@ -26,7 +26,7 @@ from grpclib.client import Channel from osm_lcm.data_utils.lcm_config import VcaConfig from osm_lcm.frontend_pb2 import PrimitiveRequest -from osm_lcm.frontend_pb2 import SshKeyRequest, SshKeyReply +from osm_lcm.frontend_pb2 import SshKeyRequest from osm_lcm.frontend_grpc import FrontendExecutorStub from osm_lcm.lcm_utils import LcmBase, get_ee_id_parts @@ -149,7 +149,7 @@ class LCMHelmConn(N2VCConnector, LcmBase): vca_type: str = None, *kargs, **kwargs, - ) -> (str, dict): + ) -> tuple[str, dict]: """ Creates a new helm execution environment deploying the helm-chat indicated in the artifact_path @@ -266,7 +266,7 @@ class LCMHelmConn(N2VCConnector, LcmBase): vca_type: str = None, *kargs, **kwargs, - ) -> (str, dict): + ) -> tuple[str, dict]: """ Creates a new helm execution environment deploying the helm-chat indicated in the attifact_path @@ -730,7 +730,7 @@ class LCMHelmConn(N2VCConnector, LcmBase): stub = FrontendExecutorStub(channel) if primitive_name == "_get_ssh_key": self.log.debug("get ssh key, ip_addr: {}".format(ip_addr)) - reply: SshKeyReply = await stub.GetSshKey(SshKeyRequest()) + reply = await stub.GetSshKey(SshKeyRequest()) return reply.message # For any other primitives async with stub.RunPrimitive.open() as stream: diff --git a/osm_lcm/n2vc/k8s_conn.py b/osm_lcm/n2vc/k8s_conn.py index 33e868a5..092a6fa5 100644 --- a/osm_lcm/n2vc/k8s_conn.py +++ b/osm_lcm/n2vc/k8s_conn.py @@ -61,7 +61,7 @@ class K8sConnector(abc.ABC, Loggable): @abc.abstractmethod async def init_env( self, k8s_creds: str, namespace: str = "kube-system", reuse_cluster_uuid=None - ) -> (str, bool): + ) -> tuple[str, bool]: """ It prepares a given K8s cluster environment to run Charts or juju Bundles on both sides: diff --git a/osm_lcm/n2vc/kubectl.py b/osm_lcm/n2vc/kubectl.py index eee63dcc..4402f113 100644 --- a/osm_lcm/n2vc/kubectl.py +++ b/osm_lcm/n2vc/kubectl.py @@ -17,7 +17,6 @@ import base64 import logging -from typing import Dict import typing import uuid import json @@ -167,7 +166,7 @@ class Kubectl: def create_cluster_role( self, name: str, - labels: Dict[str, str], + labels: typing.Dict[str, str], namespace: str = "kube-system", ): """ @@ -200,7 +199,7 @@ class Kubectl: async def create_role( self, name: str, - labels: Dict[str, str], + labels: typing.Dict[str, str], api_groups: list, resources: list, verbs: list, @@ -303,7 +302,7 @@ class Kubectl: def create_service_account( self, name: str, - labels: Dict[str, str], + labels: typing.Dict[str, str], namespace: str = "kube-system", ): """ @@ -356,7 +355,7 @@ class Kubectl: self.clients[CORE_CLIENT].delete_namespaced_service_account(name, namespace) def create_cluster_role_binding( - self, name: str, labels: Dict[str, str], namespace: str = "kube-system" + self, name: str, labels: typing.Dict[str, str], namespace: str = "kube-system" ): """ Create a cluster role binding @@ -386,7 +385,7 @@ class Kubectl: name: str, role_name: str, sa_name: str, - labels: Dict[str, str], + labels: typing.Dict[str, str], namespace: str, ): """ @@ -484,7 +483,7 @@ class Kubectl: self, name: str, namespace: str, - ) -> dict: + ) -> typing.Dict: """ Get secret data