mercredi 10 mai 2023

applying Singleton to Spotipy throws error

Spotipy's object needs to be passed a credential kw arg my code:

import spotipy
class Spoti2(spotipy.Spotify):
    spoty_obj = None
    
    @classmethod
    def __new__(cls, client_credentials_manager):
        if cls.spoty_obj is None:
            cls.spoty_obj = super().__new__(cls)
            print('se creo instancia')
        return cls.spoty_obj

but i get the error:

Spoti2.__new__() got multiple values for argument 'client_credentials_manager'

however, when I remove @classmethod, it works, and I don't know why

Aucun commentaire:

Enregistrer un commentaire