Skip to content

Commit d65485c

Browse files
bsolomon1124mattlisiv
authored andcommitted
Standardize code style with black.py + isort (mattlisiv#52)
- Run black.py on repo using pyproject.toml settings - Run `isort --atomic --recursive tests/ newsapi/ setup.py` on repo; see also https://github.com/psf/black#how-black-wraps-lines; uses .isort.cfg - Sets line length to 120 max. This is the width of GitHub source code div: see https://stackoverflow.com/a/22207921 - As of now, all flake8 checks are passing except for code complexity (C901)
1 parent 8f6f68d commit d65485c

12 files changed

+270
-226
lines changed

.flake8

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ exclude =
1010
requirements/,
1111
requirements.txt,
1212

13-
max-line-length = 127
13+
# GitHub source code UI uses 120 columns. (This varies by browser/OS,
14+
# but 120 is the least common denominator.)
15+
max-line-length = 120
1416
hang-closing = False
1517
max-complexity = 10
1618

.isort.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[settings]
2+
multi_line_output=3
3+
include_trailing_comma=True
4+
force_grid_wrap=0
5+
use_parentheses=True
6+
line_length=120

newsapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from newsapi.newsapi_client import NewsApiClient
1+
from newsapi.newsapi_client import NewsApiClient # noqa

newsapi/const.py

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,69 @@
1-
TOP_HEADLINES_URL = 'https://newsapi.org/v2/top-headlines'
2-
EVERYTHING_URL = 'https://newsapi.org/v2/everything'
3-
SOURCES_URL = 'https://newsapi.org/v2/sources'
4-
countries = {'ae','ar','at','au','be','bg','br','ca','ch','cn','co','cu','cz','de','eg','es','fr','gb','gr',
5-
'hk','hu','id','ie','il','in','is','it','jp','kr','lt','lv','ma','mx','my','ng','nl','no','nz',
6-
'ph','pk','pl','pt','ro','rs','ru','sa','se','sg','si','sk','th','tr','tw','ua','us','ve','za',
7-
'zh'}
1+
TOP_HEADLINES_URL = "https://newsapi.org/v2/top-headlines"
2+
EVERYTHING_URL = "https://newsapi.org/v2/everything"
3+
SOURCES_URL = "https://newsapi.org/v2/sources"
4+
countries = {
5+
"ae",
6+
"ar",
7+
"at",
8+
"au",
9+
"be",
10+
"bg",
11+
"br",
12+
"ca",
13+
"ch",
14+
"cn",
15+
"co",
16+
"cu",
17+
"cz",
18+
"de",
19+
"eg",
20+
"es",
21+
"fr",
22+
"gb",
23+
"gr",
24+
"hk",
25+
"hu",
26+
"id",
27+
"ie",
28+
"il",
29+
"in",
30+
"is",
31+
"it",
32+
"jp",
33+
"kr",
34+
"lt",
35+
"lv",
36+
"ma",
37+
"mx",
38+
"my",
39+
"ng",
40+
"nl",
41+
"no",
42+
"nz",
43+
"ph",
44+
"pk",
45+
"pl",
46+
"pt",
47+
"ro",
48+
"rs",
49+
"ru",
50+
"sa",
51+
"se",
52+
"sg",
53+
"si",
54+
"sk",
55+
"th",
56+
"tr",
57+
"tw",
58+
"ua",
59+
"us",
60+
"ve",
61+
"za",
62+
"zh",
63+
}
864

9-
languages = {'ar','en','cn','de','es','fr','he','it','nl','no','pt','ru','sv','se','ud','zh'}
65+
languages = {"ar", "en", "cn", "de", "es", "fr", "he", "it", "nl", "no", "pt", "ru", "sv", "se", "ud", "zh"}
1066

11-
categories = {'business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology'}
67+
categories = {"business", "entertainment", "general", "health", "science", "sports", "technology"}
1268

13-
sort_method = {'relevancy','popularity','publishedAt'}
69+
sort_method = {"relevancy", "popularity", "publishedAt"}

newsapi/newsapi_auth.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@ def __call__(self, request):
1212

1313

1414
def get_auth_headers(api_key):
15-
return {
16-
'Content-Type': 'Application/JSON',
17-
'Authorization': api_key
18-
}
15+
return {"Content-Type": "Application/JSON", "Authorization": api_key}

0 commit comments

Comments
 (0)