-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| checkout_commit(commit.hash) | ||
| all_wordcounts[commit] = get_wordcounts() | ||
| filenames.update(set(wc.filename for wc in all_wordcounts[commit])) | ||
| filenames.update({wc.filename for wc in all_wordcounts[commit]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main refactored with the following changes:
- Merge dictionary assignment with declaration
- Replace list(), dict() or set() with comprehension
| fixed_row[field] = val | ||
| else: | ||
| fixed_row[field] = 0 | ||
| fixed_row[field] = val if val else 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function get_data_from_csv refactored with the following changes:
- Replace if statement with if expression
| ROMAN_NUMERALS = ('I', 'V', 'X') | ||
| def add(augend, addend): | ||
| if not isinstance(augend, basestring) or not isinstance(addend, basestring): | ||
| if not (isinstance(augend, basestring) and isinstance(addend, basestring)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function add refactored with the following changes:
- Inline variable that is only used once
- Simplify logical expression
| else: | ||
| output_before = '' | ||
|
|
||
| output_before = fix_newlines(output_before.strip()) if output_before else '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_output refactored with the following changes:
- Replace if statement with if expression
| inseq[pos:pos + len(subseq)] == subseq | ||
| for pos in range(0, len(inseq) - len(subseq) + 1) | ||
| inseq[pos : pos + len(subseq)] == subseq | ||
| for pos in range(len(inseq) - len(subseq) + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function contains refactored with the following changes:
- Replace range(0, x) with range(x)
| print(output) | ||
| except io.BlockingIOError as e: | ||
| print(e) | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function SourceTree.run_command refactored with the following changes:
- Remove redundant pass statement
| actual2 = "AssertionError: something" | ||
| with self.assertRaises(AssertionError): | ||
| actual2 = "AssertionError: something" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function AssertConsoleOutputCorrectTest.test_ignores_3_5_x_AssertionError_None_thing refactored with the following changes:
- Move assignments closer to their usage
| actual = "qnslckvp2aga7tm6xuivyb0ob1akzzwl" | ||
| expected = Output("jvhzc8kj2mkh06xooqq9iciptead20qq") | ||
| with self.assertRaises(AssertionError): | ||
| actual = "qnslckvp2aga7tm6xuivyb0ob1akzzwl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function AssertConsoleOutputCorrectTest.test_only_ignores_exactly_32_char_strings_no_whitespace refactored with the following changes:
- Move assignments closer to their usage
|
|
||
| self.start_with_checkout() | ||
|
|
||
| vm_restore = 'MAKING_END' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Chapter9cTest.test_listings_and_commands_and_output refactored with the following changes:
- Move assignments closer to their usage
| vm_restore = 'MANUAL_END' | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Chapter9bTest.test_listings_and_commands_and_output refactored with the following changes:
- Move assignments closer to their usage
| vm_restore = 'FABRIC_END' | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Chapter18Test.test_listings_and_commands_and_output refactored with the following changes:
- Move assignments closer to their usage
| assert source.find_start_line(['indented', 'whatever']) == 4 | ||
| assert source.find_start_line([' indented', 'whatever']) == 4 | ||
| assert source.find_start_line(['no such line', 'whatever']) == None | ||
| assert source.find_start_line(['no such line', 'whatever']) is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function LineFindingTests.test_finding_start_line refactored with the following changes:
- Use x is None rather than x == None
| assert source.find_end_line(['bla bla', 'whatever']) == None | ||
| assert source.find_end_line(['no such line', 'whatever']) == None | ||
| assert source.find_end_line(['bla bla', 'whatever']) is None | ||
| assert source.find_end_line(['no such line', 'whatever']) is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function LineFindingTests.test_finding_end_line refactored with the following changes:
- Use x is None rather than x == None
| lines = [ | ||
| "def method1(self):", | ||
| " # amend method 1", | ||
| " return 2", | ||
| ] | ||
| future_lines = [ | ||
| " def method1(self):", | ||
| " # amend method 1", | ||
| " return 2", | ||
| ] | ||
| with self.assertRaises(ApplyCommitException): | ||
| lines = [ | ||
| "def method1(self):", | ||
| " # amend method 1", | ||
| " return 2", | ||
| ] | ||
| future_lines = [ | ||
| " def method1(self):", | ||
| " # amend method 1", | ||
| " return 2", | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function CheckIndentationTest.test_over_indentation_differences_are_picked_up refactored with the following changes:
- Move assignments closer to their usage
| lines = [ | ||
| "def method1(self):", | ||
| "# amend method 1", | ||
| " return 2", | ||
| ] | ||
| future_lines = [ | ||
| " def method1(self):", | ||
| " # amend method 1", | ||
| " return 2", | ||
| ] | ||
| with self.assertRaises(ApplyCommitException): | ||
| lines = [ | ||
| "def method1(self):", | ||
| "# amend method 1", | ||
| " return 2", | ||
| ] | ||
| future_lines = [ | ||
| " def method1(self):", | ||
| " # amend method 1", | ||
| " return 2", | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function CheckIndentationTest.test_under_indentation_differences_are_picked_up refactored with the following changes:
- Move assignments closer to their usage
| new_content = '\n'.join(old_lines).replace(likely_line, new_line) | ||
| return new_content | ||
| return '\n'.join(old_lines).replace(likely_line, new_line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function _replace_single_line refactored with the following changes:
- Inline variable that is only used once
| view_name = VIEW_FINDER.search(new_lines[0]).group(1) | ||
| if view_name in source.views: | ||
| return source.replace_function(new_lines) | ||
| return '\n'.join(old_lines) + '\n\n' + '\n'.join(new_lines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function _replace_lines_in refactored with the following changes:
- Merge nested if conditions
| last_line_in_our_class = max( | ||
| return max( | ||
| getattr(thing, 'lineno', 0) for thing in ast.walk(our_class) | ||
| ) | ||
| return last_line_in_our_class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function _find_last_line_for_class refactored with the following changes:
- Inline variable that is only used once
| POSSIBLE_PATH = [] | ||
|
|
||
| if sys.platform == "linux" or sys.platform == "linux2" or sys.platform == "darwin": | ||
| if sys.platform in ["linux", "linux2", "darwin"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 42-42 refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator
| ] | ||
| for arg in SYS_ARGS: | ||
| if arg == '--help' or arg == "-h": | ||
| if arg in ['--help', "-h"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 142-193 refactored with the following changes:
- Merge extend into list assignment
- Replace multiple comparisons of same variable with
inoperator
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: