From 3b0e8febc44280b5393a67ff900e0f9597b0aed7 Mon Sep 17 00:00:00 2001 From: S Murthy Date: Sun, 9 Feb 2020 12:59:20 +0000 Subject: [PATCH] Linting of core subpackage + clean up imports (#437) * Linting of OAuth2 mod. + update tests to detect core package path * Tweak imports in tests + update tox ini to ignore Flake8 E501 error * Tweak tox ini - ignore examples * Remove `f`-string from OAuth2 mod. * More import tweaks in core package + tests * Update flake8 config. in tox ini - set line length limit to 99 chars. --- spotipy/client.py | 2 +- spotipy/oauth2.py | 5 ++--- tests/integration/test_non_user_endpoints.py | 3 +-- tests/integration/test_user_endpoints.py | 6 +++--- tests/unit/test_oauth.py | 6 +++--- tox.ini | 4 +++- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spotipy/client.py b/spotipy/client.py index 08a5d64..621b4e6 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -12,10 +12,10 @@ __all__ = [ import json import sys import time +import warnings import requests import six -import warnings class SpotifyException(Exception): diff --git a/spotipy/oauth2.py b/spotipy/oauth2.py index f749974..1c8c3d1 100644 --- a/spotipy/oauth2.py +++ b/spotipy/oauth2.py @@ -29,9 +29,8 @@ class SpotifyOauthError(Exception): def _make_authorization_headers(client_id, client_secret): auth_header = base64.b64encode( six.text_type( - client_id + - ':' + - client_secret).encode('ascii')) + '{}:{}'.format(client_id, client_secret) + ).encode('ascii')) return {'Authorization': 'Basic %s' % auth_header.decode('ascii')} diff --git a/tests/integration/test_non_user_endpoints.py b/tests/integration/test_non_user_endpoints.py index 8f8e924..ae433f9 100644 --- a/tests/integration/test_non_user_endpoints.py +++ b/tests/integration/test_non_user_endpoints.py @@ -219,8 +219,7 @@ class AuthTestSpotipy(unittest.TestCase): with self.assertRaises(SpotifyException) as cm: self.spotify.user_playlist_create( "spotify", "Best hits of the 90s") - self.assertTrue(cm.exception.http_status == 401 or - cm.exception.http_status == 403) + self.assertTrue(cm.exception.http_status == 401 or cm.exception.http_status == 403) def test_custom_requests_session(self): sess = requests.Session() diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/test_user_endpoints.py index 31cc08e..9c0e191 100644 --- a/tests/integration/test_user_endpoints.py +++ b/tests/integration/test_user_endpoints.py @@ -11,17 +11,17 @@ following environment variables 'SPOTIPY_CLIENT_SECRET' 'SPOTIPY_REDIRECT_URI' """ - from __future__ import print_function +import os +import sys + from spotipy import ( CLIENT_CREDS_ENV_VARS as CCEV, prompt_for_user_token, Spotify, SpotifyException, ) -import os -import sys import unittest import warnings import requests diff --git a/tests/unit/test_oauth.py b/tests/unit/test_oauth.py index 5f169ae..8761242 100644 --- a/tests/unit/test_oauth.py +++ b/tests/unit/test_oauth.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- - -import six.moves.urllib.parse as urllibparse -from spotipy import SpotifyOAuth import io import json import unittest +import six.moves.urllib.parse as urllibparse + +from spotipy import SpotifyOAuth try: import unittest.mock as mock diff --git a/tox.ini b/tox.ini index 5d4b140..b0f5bff 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,9 @@ deps= py27: mock commands=python -m unittest discover -v tests [flake8] +max-line-length = 99 exclude= .git, dist, - docs \ No newline at end of file + docs, + examples \ No newline at end of file