Python class self value error, Expected type 'str' got Tuple[str] instead, azure ClientSecretCredential

4.5k Views Asked by At

I've created a class and trying to assign one of its values to something that expects a string, however it is saying it is getting a Tuple[str] instead, and I don't see how?

from azure.identity import ClientSecretCredential


class ServicePrincipal:
    """
    Service Principal class is used to authorise the service
    """
    def __init__(self):
        self.tenant_id = "123-xyz",
        self.client_id = "123-abc",
        self.client_secret = "123-lmn",

    def credentials(self):
        """
        Returns a ClientServiceCredential object using service principal details
        :return:
        """
        # ISSUE IS HERE 
        return ClientSecretCredential(
            tenant_id=self.tenant_id, # <---- Getting Tuple[str]
            client_id=self.client_id, # <---- Getting Tuple[str]
            client_secret=self.client_secret, # <---- Getting Tuple[str]
        )

if I copy paste the string directly into the parameter its fine. So the self.value is causing an issue somehow?

1

There are 1 best solutions below

0
On BEST ANSWER

You should remove the commas here:

def __init__(self):
        self.tenant_id = "123-xyz",  # remove the comma
        self.client_id = "123-abc",  # remove the comma
        self.client_secret = "123-lmn",  # remove the comma

Comma make the variable be a Tuple