Sourcery refactored master branch#2
Conversation
| for line in open('requirements.txt','r'): | ||
| req.append(line.split()[0]) | ||
| return req | ||
| return [line.split()[0] for line in open('requirements.txt','r')] |
There was a problem hiding this comment.
Function requirements refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| """ | ||
| results = TwitterSearchResults(self.search_tweets(order)) | ||
| return results | ||
| return TwitterSearchResults(self.search_tweets(order)) |
There was a problem hiding this comment.
Function TwitterSearch.getSearchResults refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| self.message = msg | ||
| else: | ||
| self.message = self._error_codes.get(code) | ||
| self.message = msg if msg else self._error_codes.get(code) |
There was a problem hiding this comment.
Function TwitterSearchException.__init__ refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| f = open(filename, 'r') | ||
| for line in f: | ||
| yield line | ||
| yield from f |
There was a problem hiding this comment.
Function TwitterSearchTest.apiAnsweringMachine refactored with the following changes:
- Replace yield inside for loop with yield from (
yield-from)
| for tweet in ts.search_tweets_iterable(tuo): | ||
| for _ in ts.search_tweets_iterable(tuo): |
There was a problem hiding this comment.
Function TwitterSearchTest.test_TS_search_usertimeline_iterable refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| self.assertTrue(False, "Not raising exception for lat %s, lon %s, radius %s and metric %s" % (value,value,radius,unit)) | ||
| except TwitterSearchException as e: | ||
| self.assertTrue((e.code == 1004 or e.code == 1005), "Wrong exception code") | ||
| self.assertTrue(e.code in [1004, 1005], "Wrong exception code") |
There was a problem hiding this comment.
Function TwitterSearchOrderTest.test_TSO_geo refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
|
|
||
| tso = self.getCopy() | ||
| correct_values = [ self.generateInt(minimum=1,maximum=100) for x in range(0,10) ] | ||
| correct_values = [self.generateInt(minimum=1,maximum=100) for x in range(10)] |
There was a problem hiding this comment.
Function TwitterSearchOrderTest.test_TSO_count refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range)
|
|
||
| tso = self.getCopy() | ||
| correct_values = [ self.generateString() for x in range(0,10) ] | ||
| correct_values = [self.generateString() for x in range(10)] |
There was a problem hiding this comment.
Function TwitterSearchOrderTest.test_TSO_callback refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range)
| value = "foo" | ||
| exc_class = NotImplementedError | ||
| to = TwitterOrder() | ||
| with self.assertRaises(exc_class): | ||
| value = "foo" |
There was a problem hiding this comment.
Function TwitterSearchOrderTest.test_TO_exceptions refactored with the following changes:
- Move assignments closer to their usage (
move-assign)
| data = { | ||
| return { | ||
| 'query': self.movie, | ||
| 'api-key': self.api_key | ||
| } | ||
| return data |
There was a problem hiding this comment.
Function NYTimesReviews._prepare_request_data refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.01 out of 10.
Here are some functions in these files that still need a tune-up:
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! |
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: