Sourcery refactored master branch#1
Conversation
| principal = principal - extra_payment | ||
| principal -= extra_payment | ||
| total_paid = total_paid + extra_payment | ||
|
|
||
| print(month, round(total_paid,2), round(principal, 2)) | ||
|
|
There was a problem hiding this comment.
Lines 19-23 refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign)
| else: | ||
| filename = input('Enter a filename:') | ||
|
|
||
| filename = sys.argv[1] if len(sys.argv) == 2 else input('Enter a filename:') |
There was a problem hiding this comment.
Lines 25-29 refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| bounce = 1 | ||
| while bounce <= 10: | ||
| for bounce in range(1, 11): | ||
| height = height * (3/5) | ||
| print(bounce, round(height, 4)) | ||
| bounce += 1 |
There was a problem hiding this comment.
Lines 4-8 refactored with the following changes:
- Replace while with for (
while-to-for)
| else: | ||
| filename = input('Enter a filename:') | ||
|
|
||
| filename = sys.argv[1] if len(sys.argv) == 2 else input('Enter a filename:') |
There was a problem hiding this comment.
Lines 26-30 refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| record = dict(zip(headers, row)) | ||
| else: | ||
| record = tuple(row) | ||
| record = dict(zip(headers, row)) if headers else tuple(row) |
There was a problem hiding this comment.
Function parse_csv refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| def main(args): | ||
| if len(args) != 3: | ||
| raise SystemExit('Usage: %s portfile pricefile' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfile pricefile') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| record = dict(zip(headers, row)) | ||
| else: | ||
| record = tuple(row) | ||
| record = dict(zip(headers, row)) if headers else tuple(row) |
There was a problem hiding this comment.
Function parse_csv refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| record = dict(zip(headers, row)) | ||
| else: | ||
| record = tuple(row) | ||
| record = dict(zip(headers, row)) if headers else tuple(row) |
There was a problem hiding this comment.
Function parse_csv refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| ''' | ||
| portfolio = report.read_portfolio(filename) | ||
| return sum([s.cost() for s in portfolio]) | ||
| return sum(s.cost() for s in portfolio) |
There was a problem hiding this comment.
Function portfolio_cost refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| def main(args): | ||
| if len(args) != 2: | ||
| raise SystemExit('Usage: %s portfoliofile' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| portfolio = [ Stock(d['name'], d['shares'], d['price']) for d in portdicts ] | ||
| return portfolio | ||
| return [ Stock(d['name'], d['shares'], d['price']) for d in portdicts ] |
There was a problem hiding this comment.
Function read_portfolio refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| raise SystemExit('Usage: %s portfile pricefile format' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfile pricefile format') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| record = dict(zip(headers, row)) | ||
| else: | ||
| record = tuple(row) | ||
| record = dict(zip(headers, row)) if headers else tuple(row) |
There was a problem hiding this comment.
Function parse_csv refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| ''' | ||
| portfolio = report.read_portfolio(filename) | ||
| return sum([s.cost() for s in portfolio]) | ||
| return sum(s.cost() for s in portfolio) |
There was a problem hiding this comment.
Function portfolio_cost refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| def main(args): | ||
| if len(args) != 2: | ||
| raise SystemExit('Usage: %s portfoliofile' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| @property | ||
| def total_cost(self): | ||
| return sum([s.shares * s.price for s in self._holdings]) | ||
| return sum(s.shares * s.price for s in self._holdings) |
There was a problem hiding this comment.
Function Portfolio.total_cost refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| def main(args): | ||
| if len(args) != 4: | ||
| raise SystemExit('Usage: %s portfile pricefile format' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfile pricefile format') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def main(args): | ||
| if len(args) != 4: | ||
| raise SystemExit('Usage: %s portfoliofile logfile fmt' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile logfile fmt') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| record = dict(zip(headers, row)) | ||
| else: | ||
| record = tuple(row) | ||
| record = dict(zip(headers, row)) if headers else tuple(row) |
There was a problem hiding this comment.
Function parse_csv refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| def main(args): | ||
| if len(args) != 2: | ||
| raise SystemExit('Usage: %s portfoliofile' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def main(args): | ||
| if len(args) != 4: | ||
| raise SystemExit('Usage: %s portfile pricefile format' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfile pricefile format') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def main(args): | ||
| if len(args) != 4: | ||
| raise SystemExit('Usage: %s portfoliofile logfile fmt' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile logfile fmt') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| record = dict(zip(headers, row)) | ||
| else: | ||
| record = tuple(row) | ||
| record = dict(zip(headers, row)) if headers else tuple(row) |
There was a problem hiding this comment.
Function parse_csv refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| def main(args): | ||
| if len(args) != 2: | ||
| raise SystemExit('Usage: %s portfoliofile' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def __contains__(self, name): | ||
| return any([s.name == name for s in self._holdings]) | ||
| return any(s.name == name for s in self._holdings) |
There was a problem hiding this comment.
Function Portfolio.__contains__ refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| def main(args): | ||
| if len(args) != 4: | ||
| raise SystemExit('Usage: %s portfoliofile logfile fmt' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile logfile fmt') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
|
|
||
| def typedproperty(name, expected_type): | ||
| private_name = '_' + name | ||
| private_name = f'_{name}' |
There was a problem hiding this comment.
Function typedproperty refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| record = dict(zip(headers, row)) | ||
| else: | ||
| record = tuple(row) | ||
| record = dict(zip(headers, row)) if headers else tuple(row) |
There was a problem hiding this comment.
Function parse_csv refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| def main(args): | ||
| if len(args) != 2: | ||
| raise SystemExit('Usage: %s portfoliofile' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfoliofile') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| def main(args): | ||
| if len(args) != 4: | ||
| raise SystemExit('Usage: %s portfile pricefile format' % args[0]) | ||
| raise SystemExit(f'Usage: {args[0]} portfile pricefile format') |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
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:Help us improve this pull request!