spotipy-dev / spotipy

A light weight Python library for the Spotify Web API
http://spotipy.readthedocs.org
MIT License
5.03k stars 957 forks source link

Importing throws TypeError #1022

Closed alexklann closed 1 year ago

alexklann commented 1 year ago

Describe the bug Importing spotipy into my project throws a TypeError

Your code

import spotipy
from spotipy.oauth2 import SpotifyOAuth

scope = "user-library-read"

sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))

results = sp.current_user_saved_tracks()
for idx, item in enumerate(results['items']):
    track = item['track']
    print(idx, track['artists'][0]['name'], " – ", track['name'])

Output

TypeError                                 Traceback (most recent call last)
[~\AppData\Local\Temp\ipykernel_19968\136658583.py](https://file+.vscode-resource.vscode-cdn.net/d%3A/Coding/~/AppData/Local/Temp/ipykernel_19968/136658583.py) in 
----> 1 import spotipy
      2 from spotipy.oauth2 import SpotifyOAuth
      3 
      4 scope = "user-library-read"
      5 

[c:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\spotipy\__init__.py](file:///C:/Users/user/AppData/Local/Programs/Python/Python37/lib/site-packages/spotipy/__init__.py) in 
----> 1 from .cache_handler import *  # noqa
      2 from .client import *  # noqa
      3 from .exceptions import *  # noqa
      4 from .oauth2 import *  # noqa
      5 from .util import *  # noqa

[c:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\spotipy\cache_handler.py](file:///C:/Users/user/AppData/Local/Programs/Python/Python37/lib/site-packages/spotipy/cache_handler.py) in 
     13 from spotipy.util import CLIENT_CREDS_ENV_VARS
     14 
---> 15 from redis import RedisError
     16 
     17 logger = logging.getLogger(__name__)

[c:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\redis\__init__.py](file:///C:/Users/user/AppData/Local/Programs/Python/Python37/lib/site-packages/redis/__init__.py) in 
      1 import sys
...
--> 135         raise TypeError(f"Plain {arg} is not valid as type argument")
    136     if isinstance(arg, (type, TypeVar, ForwardRef)):
    137         return arg

TypeError: Plain typing.NoReturn is not valid as type argument

Environment:

dieser-niko commented 1 year ago

Can you specify what caused this to happen?

alexklann commented 1 year ago

This just randomly vanished when I tried this in an actual python project and not in a jupyter notebook