Skip to content

Commit 9688a25

Browse files
committed
isort, newer version of black
1 parent fcc97d5 commit 9688a25

25 files changed

+44
-56
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ install:
88
- pip install .[test]
99
before_script:
1010
- flake8 .
11-
- black . --check
11+
- black --check .
1212
script:
1313
- python setup.py test --pytest-args "tests/ --cov=./"
1414
after_success:

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Removed support for Python 2, Python 3.4 and Python 3.5
88
- Added support for Python 3.7 and 3.8
99
- Added new code formatting called black
10+
- Changed import orders to now be formatted via isort
1011
- Added TwitchHelix.get_oauth() for fetching OAuth access token
1112
- Updated docs
1213

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ cov:
66

77
cov-html:
88
py.test --cov=./ --cov-report html
9+
10+
format:
11+
isort .
12+
black .
13+
14+
lint:
15+
flake8 .
16+
black --check .

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ license_file = LICENSE
44

55
[flake8]
66
max-line-length = 100
7-
select = E,W,F,N,I,C
7+
select = E,W,F,I,C
88
ignore = W503
99
exclude = docs/
1010
application-import-names = twitch

setup.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ def run_tests(self):
3535
requires = ["requests>=2.23.0"]
3636

3737
test_requirements = [
38-
"black==19.10b0",
39-
"codecov>=2.1.4",
40-
"flake8-import-order>=0.18.1",
41-
"flake8>=3.8.3",
42-
"pytest-cov>=2.9.0",
43-
"pytest>=3",
44-
"responses>=0.10.15",
38+
"black==20.8b1",
39+
"codecov>=2.1.10",
40+
"flake8-isort>=4.0.0",
41+
"flake8>=3.8.4",
42+
"isort>=5.6.4",
43+
"pytest-cov>=2.10.1",
44+
"pytest>=6.1.2",
45+
"responses>=0.12.1",
4546
]
4647

47-
doc_reqs = ["Sphinx==3.1.0", "sphinx-autobuild==0.7.1", "sphinx_rtd_theme==0.4.3"]
48+
doc_reqs = ["Sphinx==3.3.1", "sphinx_rtd_theme==0.5.0"]
4849

4950
extras_require = {
5051
"doc": doc_reqs,
@@ -72,9 +73,7 @@ def run_tests(self):
7273
author="Tomaz Sifrer",
7374
author_email="[email protected]",
7475
url="https://github.com/tsifrer/python-twitch-client",
75-
packages=setuptools.find_packages(
76-
exclude=["tests", "tests.*", "samples", "samples.*"]
77-
),
76+
packages=["twitch"],
7877
cmdclass=cmdclass,
7978
install_requires=requires,
8079
tests_require=test_requirements,

tests/api/test_base.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
import os
33

44
import pytest
5-
6-
from requests import exceptions
7-
85
import responses
6+
from requests import exceptions
97

108
from twitch.api.base import BASE_URL, TwitchAPI
119

12-
1310
dummy_data = {"spongebob": "squarepants"}
1411

1512

tests/api/test_channel_feed.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient

tests/api/test_channels.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Channel, Community, Follow, Subscription, Team, User, Video
1110

12-
1311
example_user = {
1412
"_id": "44322889",
1513
"name": "dallas",

tests/api/test_chat.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from twitch.client import TwitchClient
66
from twitch.constants import BASE_URL
77

8-
98
example_emote = {"code": "TwitchLit", "id": 115390}
109

1110

tests/api/test_collections.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Collection, Item
1110

12-
1311
example_collection = {
1412
"_id": "myIbIFkZphQSbQ",
1513
"items_count": 3,

tests/api/test_communities.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Community, User
1110

12-
1311
example_community = {
1412
"_id": "e9f17055-810f-4736-ba40-fba4ac541caa",
1513
"name": "DallasTesterCommunity",

tests/api/test_games.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Game, TopGame
1110

12-
1311
example_top_games_response = {
1412
"_total": 1157,
1513
"top": [

tests/api/test_ingests.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from twitch.constants import BASE_URL
77
from twitch.resources import Ingest
88

9-
109
example_response = {"ingests": [{"_id": 24, "name": "EU: Amsterdam, NL"}]}
1110

1211

tests/api/test_search.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Channel, Game, Stream
1110

12-
1311
example_channel = {
1412
"_id": 44322889,
1513
"name": "dallas",

tests/api/test_streams.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient

tests/api/test_teams.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Team
1110

12-
1311
example_team_response = {
1412
"_id": 10,
1513
"name": "staff",

tests/api/test_users.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Channel, Follow, Subscription, User, UserBlock
1110

12-
1311
example_user = {
1412
"_id": "44322889",
1513
"name": "dallas",

tests/api/test_videos.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import json
22

33
import pytest
4-
54
import responses
65

76
from twitch.client import TwitchClient
87
from twitch.constants import BASE_URL, VOD_FETCH_URL
98
from twitch.exceptions import TwitchAttributeException
109
from twitch.resources import Video
1110

12-
1311
example_video_response = {
1412
"_id": "v106400740",
1513
"description": "Protect your chat with AutoMod!",

tests/helix/test_api.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from datetime import datetime
33

44
import pytest
5-
65
import responses
76

87
from twitch import TwitchHelix
@@ -112,17 +111,15 @@
112111
"access_token": "xxxxxx",
113112
"expires_in": 123456,
114113
"token_type": "bearer",
115-
"scope":["analytics:read:extensions"]
114+
"scope": ["analytics:read:extensions"],
116115
}
117116

118117
example_get_oauth_error_response = {
119118
"status": 400,
120119
"message": "missing client secret",
121120
}
122121

123-
example_get_oauth_bad_request = {
124-
"status": 401
125-
}
122+
example_get_oauth_bad_request = {"status": 401}
126123

127124
example_get_videos_response = {
128125
"data": [
@@ -215,6 +212,7 @@ def test_get_oauth_returns_oauth_token():
215212

216213
assert client._oauth_token
217214

215+
218216
@responses.activate
219217
def test_get_oauth_returns_oauth_token_with_scopes():
220218
responses.add(
@@ -225,9 +223,12 @@ def test_get_oauth_returns_oauth_token_with_scopes():
225223
content_type="application/json",
226224
)
227225

228-
client = TwitchHelix("client id", client_secret="client secret",scopes=['analytics:read:extensions'])
226+
client = TwitchHelix(
227+
"client id", client_secret="client secret", scopes=["analytics:read:extensions"]
228+
)
229229
client.get_oauth()
230230

231+
231232
@responses.activate
232233
def test_get_oauth_raises_oauth_exception_bad_request():
233234
responses.add(
@@ -238,10 +239,11 @@ def test_get_oauth_raises_oauth_exception_bad_request():
238239
content_type="application/json",
239240
)
240241

241-
client = TwitchHelix("client id",client_secret='client secret')
242+
client = TwitchHelix("client id", client_secret="client secret")
242243
with pytest.raises(TwitchOAuthException):
243244
client.get_oauth()
244245

246+
245247
@responses.activate
246248
def test_get_oauth_raises_oauth_exception_worse_request():
247249
responses.add(
@@ -252,10 +254,11 @@ def test_get_oauth_raises_oauth_exception_worse_request():
252254
content_type="application/json",
253255
)
254256

255-
client = TwitchHelix("client id",client_secret='client secret')
257+
client = TwitchHelix("client id", client_secret="client secret")
256258
with pytest.raises(TwitchOAuthException):
257259
client.get_oauth()
258260

261+
259262
def test_get_oauth_raises_oauth_exception_missing_secret():
260263
client = TwitchHelix("client id")
261264
with pytest.raises(TwitchOAuthException):

twitch/api/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from .clips import Clips # noqa
21
from .channel_feed import ChannelFeed # noqa
32
from .channels import Channels # noqa
43
from .chat import Chat # noqa
4+
from .clips import Clips # noqa
55
from .collections import Collections # noqa
66
from .communities import Communities # noqa
77
from .games import Games # noqa

twitch/api/channels.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from twitch.api.base import TwitchAPI
22
from twitch.constants import (
3-
BROADCAST_TYPES,
43
BROADCAST_TYPE_HIGHLIGHT,
5-
DIRECTIONS,
4+
BROADCAST_TYPES,
65
DIRECTION_ASC,
76
DIRECTION_DESC,
8-
VIDEO_SORTS,
7+
DIRECTIONS,
98
VIDEO_SORT_TIME,
9+
VIDEO_SORTS,
1010
)
1111
from twitch.decorators import oauth_required
1212
from twitch.exceptions import TwitchAttributeException

twitch/api/streams.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from twitch.api.base import TwitchAPI
2-
from twitch.constants import STREAM_TYPES, STREAM_TYPE_LIVE
2+
from twitch.constants import STREAM_TYPE_LIVE, STREAM_TYPES
33
from twitch.decorators import oauth_required
44
from twitch.exceptions import TwitchAttributeException
55
from twitch.resources import Featured, Stream

twitch/api/users.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from twitch.api.base import TwitchAPI
22
from twitch.constants import (
3-
DIRECTIONS,
43
DIRECTION_DESC,
4+
DIRECTIONS,
55
MAX_FOLLOWS_LIMIT,
66
USERS_SORT_BY,
77
USERS_SORT_BY_CREATED_AT,

twitch/api/videos.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from twitch.api.base import TwitchAPI
22
from twitch.constants import (
3-
BROADCAST_TYPES,
43
BROADCAST_TYPE_HIGHLIGHT,
5-
PERIODS,
4+
BROADCAST_TYPES,
65
PERIOD_WEEK,
6+
PERIODS,
77
VOD_FETCH_URL,
88
)
99
from twitch.decorators import oauth_required

twitch/helix/api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
from twitch.conf import credentials_from_config_file
44
from twitch.constants import (
55
BASE_OAUTH_URL,
6-
PERIODS,
76
PERIOD_ALL,
8-
VIDEO_SORTS,
7+
PERIODS,
98
VIDEO_SORT_TIME,
10-
VIDEO_TYPES,
9+
VIDEO_SORTS,
1110
VIDEO_TYPE_ALL,
11+
VIDEO_TYPES,
1212
)
1313
from twitch.exceptions import TwitchAttributeException, TwitchOAuthException
1414
from twitch.helix.base import APICursor, APIGet

0 commit comments

Comments
 (0)