Skip to content

Commit 8e01f16

Browse files
committed
fix lint
1 parent 5f1cc0f commit 8e01f16

File tree

7 files changed

+34
-43
lines changed

7 files changed

+34
-43
lines changed

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ ignore =
88
violations.flake8.txt
99

1010
[flake8]
11-
ignore = E111,E124,E126,E201,E202,E221,E241,E302,E501
11+
ignore = E111,E124,E126,E202,E221,E241,E302,E501
1212

1313
[pep8]
14-
ignore = E111,E124,E126,E128,E201,E202,E221,E226,E241,E301,E302,E303,E402,E501,W291
14+
ignore = E111,E124,E126,E202,E221,E241,E302,E501
1515
max-line-length = 160

tests/test_api_30.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
import twitter
1111

12-
warnings.filterwarnings('ignore', category=DeprecationWarning)
13-
1412
import responses
1513
from responses import GET, POST
1614

15+
warnings.filterwarnings('ignore', category=DeprecationWarning)
16+
17+
1718
DEFAULT_URL = re.compile(r'https?://.*\.twitter.com/1\.1/.*')
1819

1920

@@ -205,7 +206,6 @@ def testGetTrendsCurrent(self):
205206
# lambda: self.api.GetHomeTimeline(
206207
# since_id='still infinity'))
207208

208-
209209
# # TODO: Get data for this call against which we can test exclusions.
210210
# responses.add(
211211
# responses.GET,
@@ -461,29 +461,29 @@ def testGetFriendsAdditionalParams(self):
461461
# @responses.activate
462462
# def testGetFriends(self):
463463

464-
# """
465-
# This is tedious, but the point is to add a responses endpoint for
466-
# each call that GetFriends() is going to make against the API and
467-
# have it return the appropriate json data.
468-
# """
464+
# """
465+
# This is tedious, but the point is to add a responses endpoint for
466+
# each call that GetFriends() is going to make against the API and
467+
# have it return the appropriate json data.
468+
# """
469469

470-
# cursor = -1
471-
# for i in range(0, 5):
472-
# with open('testdata/get_friends_{0}.json'.format(i)) as f:
473-
# resp_data = f.read()
474-
# endpoint = '/friends/list.json?screen_name=codebear&count=200&skip_status=False&include_user_entities=True&cursor={0}'.format(cursor)
470+
# cursor = -1
471+
# for i in range(0, 5):
472+
# with open('testdata/get_friends_{0}.json'.format(i)) as f:
473+
# resp_data = f.read()
474+
# endpoint = '/friends/list.json?screen_name=codebear&count=200&skip_status=False&include_user_entities=True&cursor={0}'.format(cursor)
475475

476-
# responses.add(
477-
# responses.GET,
478-
# '{base_url}{endpoint}'.format(
479-
# base_url=self.api.base_url,
480-
# endpoint=endpoint),
481-
# body=resp_data, match_querystring=True, status=200)
476+
# responses.add(
477+
# responses.GET,
478+
# '{base_url}{endpoint}'.format(
479+
# base_url=self.api.base_url,
480+
# endpoint=endpoint),
481+
# body=resp_data, match_querystring=True, status=200)
482482

483-
# cursor = json.loads(resp_data)['next_cursor']
483+
# cursor = json.loads(resp_data)['next_cursor']
484484

485-
# resp = self.api.GetFriends(screen_name='codebear')
486-
# self.assertEqual(len(resp), 819)
485+
# resp = self.api.GetFriends(screen_name='codebear')
486+
# self.assertEqual(len(resp), 819)
487487

488488
@responses.activate
489489
def testGetFriendsWithLimit(self):
@@ -1353,7 +1353,6 @@ def testGetStatusWithExtAltText(self):
13531353
resp = self.api.GetStatus(status_id=724441953534877696)
13541354
self.assertEqual(resp.media[0].ext_alt_text, "\u201cJon Snow is dead.\u2026\u201d from \u201cGAME OF THRONES SEASON 6 EPISODES\u201d by HBO PR.")
13551355

1356-
13571356
@responses.activate
13581357
def testGetStatus(self):
13591358
with open('testdata/get_status.json') as f:
@@ -1380,7 +1379,6 @@ def testGetStatusExtraParams(self):
13801379
resp = self.api.GetStatus(status_id=397, trim_user=True, include_entities=False)
13811380
self.assertFalse(resp.user.screen_name)
13821381

1383-
13841382
# @responses.activate
13851383
# def testGetStatusOembed(self):
13861384
# with open('testdata/get_status_oembed.json') as f:

tests/test_error_handling.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
import warnings
99

1010
import twitter
11-
12-
warnings.filterwarnings('ignore', category=DeprecationWarning)
13-
1411
import responses
1512
from responses import GET, POST
1613

14+
warnings.filterwarnings('ignore', category=DeprecationWarning)
15+
1716
DEFAULT_URL = re.compile(r'https?://.*\.twitter.com/1\.1/.*')
1817
BODY = b'{"request":"\\/1.1\\/statuses\\/user_timeline.json","error":"Not authorized."}'
1918

tests/test_tweet_changes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
import warnings
99

1010
import twitter
11-
12-
warnings.filterwarnings('ignore', category=DeprecationWarning)
13-
1411
import responses
1512
from responses import GET
1613

14+
warnings.filterwarnings('ignore', category=DeprecationWarning)
15+
1716
DEFAULT_URL = re.compile(r'https?://.*\.twitter.com/1\.1/.*')
1817

1918

twitter/parse_tweet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, timeline_owner, tweet):
5151
self.Emoticon = ParseTweet.getAttributeEmoticon(tweet)
5252

5353
# additional intelligence
54-
if ( self.RT and len(self.UserHandles) > 0 ): # change the owner of tweet?
54+
if (self.RT and len(self.UserHandles) > 0): # change the owner of tweet?
5555
self.Owner = self.UserHandles[0]
5656
return
5757

@@ -66,10 +66,10 @@ def getAttributeEmoticon(tweet):
6666
emoji = list()
6767
for tok in re.split(ParseTweet.regexp["SPACES"], tweet.strip()):
6868
if tok in Emoticons.POSITIVE:
69-
emoji.append( tok )
69+
emoji.append(tok)
7070
continue
7171
if tok in Emoticons.NEGATIVE:
72-
emoji.append( tok )
72+
emoji.append(tok)
7373
return emoji
7474

7575
@staticmethod

twitter/ratelimit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ def url_to_resource(url):
118118
for non_std_endpoint in NON_STANDARD_ENDPOINTS:
119119
if re.match(non_std_endpoint.regex, resource):
120120
return non_std_endpoint.resource
121-
else:
122-
return resource
121+
return resource
123122

124123
def set_unknown_limit(self, url, limit, remaining, reset):
125124
return self.set_limit(url, limit, remaining, reset)

twitter/twitter_utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
import mimetypes
33
import os
44
import re
5-
6-
import requests
75
from tempfile import NamedTemporaryFile
86

7+
import requests
98
from twitter import TwitterError
109

1110

@@ -171,10 +170,7 @@ def is_url(text):
171170
Returns:
172171
Boolean of whether the text should be treated as a URL or not.
173172
"""
174-
if re.findall(URL_REGEXP, text):
175-
return True
176-
else:
177-
return False
173+
return bool(re.findall(URL_REGEXP, text))
178174

179175

180176
def http_to_file(http):

0 commit comments

Comments
 (0)