[GH-ISSUE #1022] Importing throws TypeError #609

Closed
opened 2026-02-28 00:00:14 +03:00 by kerem · 2 comments
Owner

Originally created by @alexklann on GitHub (Aug 20, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1022

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:

  • OS: Windows
  • Python version 3.7.0
  • spotipy version 2.23.0
  • your IDE (if using any): VSCode
Originally created by @alexklann on GitHub (Aug 20, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1022 **Describe the bug** Importing spotipy into my project throws a TypeError **Your code** ```python 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:** - OS: Windows - Python version 3.7.0 - spotipy version 2.23.0 - your IDE (if using any): VSCode
kerem 2026-02-28 00:00:14 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@dieser-niko commented on GitHub (Aug 21, 2023):

Can you specify what caused this to happen?

<!-- gh-comment-id:1685810376 --> @dieser-niko commented on GitHub (Aug 21, 2023): Can you specify what caused this to happen?
Author
Owner

@alexklann commented on GitHub (Aug 21, 2023):

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

<!-- gh-comment-id:1685839652 --> @alexklann commented on GitHub (Aug 21, 2023): This just randomly vanished when I tried this in an actual python project and not in a jupyter notebook
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#609
No description provided.