-
Notifications
You must be signed in to change notification settings - Fork 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
Sourcery Starbot ⭐ refactored ccombe/practical-python #1
base: master
Are you sure you want to change the base?
Conversation
month = month + 1 | ||
month += 1 | ||
principal = principal * (1+rate/12) - payment | ||
total_paid = total_paid + payment | ||
total_paid += payment | ||
|
||
if month >= extra_payment_start_month and month <= extra_payment_end_month: | ||
principal = principal - extra_payment | ||
total_paid = total_paid + extra_payment | ||
principal -= extra_payment | ||
total_paid += extra_payment | ||
|
||
print(month, round(total_paid,2), round(principal, 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.
Lines 14-23
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
)
if len(sys.argv) == 2: | ||
filename = sys.argv[1] | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 25-29
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
bounce = 1 | ||
while bounce <= 10: | ||
height = height * (3/5) | ||
for bounce in range(1, 11): | ||
height *= 3/5 | ||
print(bounce, round(height, 4)) | ||
bounce += 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.
Lines 4-8
refactored with the following changes:
- Replace assignment with augmented assignment (
aug-assign
) - Replace while with for (
while-to-for
)
if len(sys.argv) == 2: | ||
filename = sys.argv[1] | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 26-30
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function read_portfolio
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
return sum([s.cost() for s in portfolio]) | ||
return sum(s.cost() for s in portfolio) |
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 portfolio_cost
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function read_portfolio
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
return sum([s.cost() for s in portfolio]) | ||
return sum(s.cost() for s in portfolio) |
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 portfolio_cost
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function read_portfolio
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Portfolio.__contains__
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Portfolio.total_cost
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
if headers: | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_csv
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
s = '"%s",%0.2f,"%s","%s",%0.2f,%0.2f,%0.2f,%0.2f,%d' % tuple(fields) | ||
return s | ||
return '"%s",%0.2f,"%s","%s",%0.2f,%0.2f,%0.2f,%0.2f,%d' % tuple(fields) |
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 csv_record
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: