Skip to content

Commit

Permalink
fix: C0415: Import outside toplevel
Browse files Browse the repository at this point in the history
  • Loading branch information
esolitos committed Jan 3, 2024
1 parent 473d7ad commit 5f11ef5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions swa/spotifyoauthredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
This module contains functions for handling Spotify OAuth and cached access tokens.
"""

import logging
from os import getenv

import spotipy
import hashlib
import logging
import redis
import spotipy

from swa.utils import http_server_info

Expand Down Expand Up @@ -36,18 +37,15 @@ def spotify_oauth(email: str) -> spotipy.SpotifyOAuth:

cache_handler = None
if getenv('REDIS_URL'):
from spotipy.cache_handler import RedisCacheHandler
rclient = redis.Redis().from_url(url=getenv('REDIS_URL'), decode_responses=True)
cache_handler = RedisCacheHandler(
cache_handler = spotipy.cache_handler.RedisCacheHandler(
rclient,
'-'.join(('swa-user', email)),
)
else:
from hashlib import sha1
from spotipy.oauth2 import CacheFileHandler
cache_handler = CacheFileHandler(
cache_handler = spotipy.oauth2.CacheFileHandler(
cache_path='.cache/user-%s' %
sha1(
hashlib.sha1(
email.encode(),
usedforsecurity=False).hexdigest())

Expand Down

0 comments on commit 5f11ef5

Please sign in to comment.