Skip to content

Commit

Permalink
Linting of core subpackage + clean up imports (#437)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
sr-murthy authored Feb 9, 2020
1 parent c22ba27 commit 3b0e8fe
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion spotipy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import json
import sys
import time
import warnings

import requests
import six
import warnings


class SpotifyException(Exception):
Expand Down
5 changes: 2 additions & 3 deletions spotipy/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}


Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_non_user_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ def test_unauthenticated_post_fails(self):
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()
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_user_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
'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
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_oauth.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ deps=
py27: mock
commands=python -m unittest discover -v tests
[flake8]
max-line-length = 99
exclude=
.git,
dist,
docs
docs,
examples

0 comments on commit 3b0e8fe

Please sign in to comment.