Skip to content

Commit 265b8dd

Browse files
committed
- Change instances of 'string' to 'str' where appropriate, in Comments and Error Messages.
1 parent 9e08c5f commit 265b8dd

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

newsapi/newsapi_client.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get_top_headlines(self, q=None, sources=None, language=None, country=None, c
4848
if type(q) == str:
4949
payload['q'] = q
5050
else:
51-
raise TypeError('keyword/phrase q param should be a string')
51+
raise TypeError('keyword/phrase q param should be a of type str')
5252

5353
# Sources
5454
if (sources is not None) and ((country is not None) or (category is not None)):
@@ -59,7 +59,7 @@ def get_top_headlines(self, q=None, sources=None, language=None, country=None, c
5959
if type(sources) == str:
6060
payload['sources'] = sources
6161
else:
62-
raise TypeError('sources param should be a string')
62+
raise TypeError('sources param should be of type str')
6363

6464
# Language
6565
if language is not None:
@@ -69,7 +69,7 @@ def get_top_headlines(self, q=None, sources=None, language=None, country=None, c
6969
else:
7070
raise ValueError('invalid language')
7171
else:
72-
raise TypeError('language param should be a string')
72+
raise TypeError('language param should be of type str')
7373

7474
# Country
7575
if country is not None:
@@ -79,7 +79,7 @@ def get_top_headlines(self, q=None, sources=None, language=None, country=None, c
7979
else:
8080
raise ValueError('invalid country')
8181
else:
82-
raise TypeError('country param should be a string')
82+
raise TypeError('country param should be of type str')
8383

8484
# Category
8585
if category is not None:
@@ -89,7 +89,7 @@ def get_top_headlines(self, q=None, sources=None, language=None, country=None, c
8989
else:
9090
raise ValueError('invalid category')
9191
else:
92-
raise TypeError('category param should be a string')
92+
raise TypeError('category param should be of type str')
9393

9494
# Page Size
9595
if page_size is not None:
@@ -160,21 +160,21 @@ def get_everything(self, q=None, sources=None, domains=None, from_param=None, to
160160
if type(q) == str:
161161
payload['q'] = q
162162
else:
163-
raise TypeError('keyword/phrase q param should be a str')
163+
raise TypeError('keyword/phrase q param should be of type str')
164164

165165
# Sources
166166
if sources is not None:
167167
if type(sources) == str:
168168
payload['sources'] = sources
169169
else:
170-
raise TypeError('sources param should be a str')
170+
raise TypeError('sources param should be of type str')
171171

172172
# Domains To Search
173173
if domains is not None:
174174
if type(domains) == str:
175175
payload['domains'] = domains
176176
else:
177-
raise TypeError('domains param should be a string')
177+
raise TypeError('domains param should be of type str')
178178

179179
# Search From This Date ...
180180
if from_param is not None:
@@ -188,7 +188,7 @@ def get_everything(self, q=None, sources=None, domains=None, from_param=None, to
188188
else:
189189
raise ValueError('from_param should be in the format of YYYY-MM-DD')
190190
else:
191-
raise TypeError('from_param should be a string')
191+
raise TypeError('from_param should be of type str')
192192

193193
# ... To This Date
194194
if to is not None:
@@ -202,7 +202,7 @@ def get_everything(self, q=None, sources=None, domains=None, from_param=None, to
202202
else:
203203
raise ValueError('to param should be in the format of YYYY-MM-DD')
204204
else:
205-
raise TypeError('to param should be a string')
205+
raise TypeError('to param should be of type str')
206206

207207
# Language
208208
if language is not None:
@@ -212,7 +212,7 @@ def get_everything(self, q=None, sources=None, domains=None, from_param=None, to
212212
else:
213213
payload['language'] = language
214214
else:
215-
raise TypeError('language param should be a string')
215+
raise TypeError('language param should be of type str')
216216

217217
# Sort Method
218218
if sort_by is not None:
@@ -222,7 +222,7 @@ def get_everything(self, q=None, sources=None, domains=None, from_param=None, to
222222
else:
223223
raise ValueError('invalid sort')
224224
else:
225-
raise TypeError('sort_by param should be a string')
225+
raise TypeError('sort_by param should be of type str')
226226

227227
# Page Size
228228
if page_size is not None:
@@ -285,7 +285,7 @@ def get_sources(self, category=None, language=None, country=None):
285285
else:
286286
raise ValueError('invalid language')
287287
else:
288-
raise TypeError('language param should be a string')
288+
raise TypeError('language param should be of type str')
289289

290290
# Country
291291
if country is not None:
@@ -295,7 +295,7 @@ def get_sources(self, category=None, language=None, country=None):
295295
else:
296296
raise ValueError('invalid country')
297297
else:
298-
raise TypeError('country param should be a string')
298+
raise TypeError('country param should be of type str')
299299

300300
# Category
301301
if category is not None:
@@ -305,7 +305,7 @@ def get_sources(self, category=None, language=None, country=None):
305305
else:
306306
raise ValueError('invalid category')
307307
else:
308-
raise TypeError('category param should be a string')
308+
raise TypeError('category param should be of type str')
309309

310310
# Send Request
311311
r = requests.get(const.SOURCES_URL, auth=self.auth, timeout=30, params=payload)

tests/test_newsapi_client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def setUp(self):
1010
self.api = NewsApiClient(key)
1111

1212
def test_api_top_headline(self):
13-
# Raise TypeError if Keyword/Phrase param is not a string
13+
# Raise TypeError if Keyword/Phrase param is not of type str
1414
q = 0
1515
with self.assertRaises(TypeError):
1616
self.api.get_top_headlines(q=q)
@@ -22,12 +22,12 @@ def test_api_top_headline(self):
2222
with self.assertRaises(ValueError):
2323
self.api.get_top_headlines(sources=sources, country=country, category=category)
2424

25-
# Raise TypeError if sources param is not a string
25+
# Raise TypeError if sources param is not of type str
2626
sources = 0
2727
with self.assertRaises(TypeError):
2828
self.api.get_top_headlines(sources=sources)
2929

30-
# Raise TypeError if language param is not a string
30+
# Raise TypeError if language param is not of type str
3131
language = 0
3232
with self.assertRaises(TypeError):
3333
self.api.get_top_headlines(language=language)
@@ -37,7 +37,7 @@ def test_api_top_headline(self):
3737
with self.assertRaises(ValueError):
3838
self.api.get_top_headlines(language=language)
3939

40-
# Raise TypeError if country param is not a string
40+
# Raise TypeError if country param is not of type str
4141
country = 0
4242
with self.assertRaises(TypeError):
4343
self.api.get_top_headlines(country=country)
@@ -47,7 +47,7 @@ def test_api_top_headline(self):
4747
with self.assertRaises(ValueError):
4848
self.api.get_top_headlines(country=country)
4949

50-
# Raises TypeError if category param is not a string
50+
# Raises TypeError if category param is not of type str
5151
category = 0
5252
with self.assertRaises(TypeError):
5353
self.api.get_top_headlines(category=category)
@@ -87,17 +87,17 @@ def test_api_get_everything(self):
8787
with self.assertRaises(TypeError):
8888
self.api.get_everything(q=q)
8989

90-
# Raise TypeError if sources param is not a string
90+
# Raise TypeError if sources param is not of type str
9191
sources = 0
9292
with self.assertRaises(TypeError):
9393
self.api.get_everything(sources=sources)
9494

95-
# Raise TypeError is domains param is not a string
95+
# Raise TypeError is domains param is not of type str
9696
domains = 0
9797
with self.assertRaises(TypeError):
9898
self.api.get_everything(domains=domains)
9999

100-
# Raise TypeError is from_param param is not a string
100+
# Raise TypeError is from_param param is not of type str
101101
from_param = 0
102102
with self.assertRaises(TypeError):
103103
self.api.get_everything(from_param=from_param)
@@ -107,7 +107,7 @@ def test_api_get_everything(self):
107107
with self.assertRaises(ValueError):
108108
self.api.get_everything(from_param=from_param)
109109

110-
# Raise TypeError if to param is not a string
110+
# Raise TypeError if to param is not of type str
111111
to = 1
112112
with self.assertRaises(TypeError):
113113
self.api.get_everything(to=to)
@@ -117,7 +117,7 @@ def test_api_get_everything(self):
117117
with self.assertRaises(ValueError):
118118
self.api.get_everything(to=to)
119119

120-
# Raise TypeError if language param is not a string
120+
# Raise TypeError if language param is not of type str
121121
language = 0
122122
with self.assertRaises(TypeError):
123123
self.api.get_everything(language=language)
@@ -127,7 +127,7 @@ def test_api_get_everything(self):
127127
with self.assertRaises(ValueError):
128128
self.api.get_everything(language=language)
129129

130-
# Raise TypeError is sort_by param is not a string
130+
# Raise TypeError is sort_by param is not of type str
131131
sort_by = 1
132132
with self.assertRaises(TypeError):
133133
self.api.get_everything(sort_by=sort_by)
@@ -162,7 +162,7 @@ def test_api_get_everything(self):
162162
self.api.get_everything(page=page)
163163

164164
def test_api_get_sources(self):
165-
# Raise TypeError if language param is not a string
165+
# Raise TypeError if language param is not of type str
166166
language = 0
167167
with self.assertRaises(TypeError):
168168
self.api.get_sources(language=language)
@@ -172,7 +172,7 @@ def test_api_get_sources(self):
172172
with self.assertRaises(ValueError):
173173
self.api.get_sources(language=language)
174174

175-
# Raise TypeError if country param is not a string
175+
# Raise TypeError if country param is not of type str
176176
country = 0
177177
with self.assertRaises(TypeError):
178178
self.api.get_sources(country=country)
@@ -182,7 +182,7 @@ def test_api_get_sources(self):
182182
with self.assertRaises(ValueError):
183183
self.api.get_sources(country=country)
184184

185-
# Raises TypeError if category param is not a string
185+
# Raises TypeError if category param is not of type str
186186
category = 0
187187
with self.assertRaises(TypeError):
188188
self.api.get_sources(category=category)

0 commit comments

Comments
 (0)