Skip to content

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit intomasterfrom
sourcery/master

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 1, 2020

Branch master refactored 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 master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -14 to +23
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))

Copy link
Author

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

else:
filename = input('Enter a filename:')

filename = sys.argv[1] if len(sys.argv) == 2 else input('Enter a filename:')
Copy link
Author

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

Comment on lines -4 to -8
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
Copy link
Author

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
  • Replace while with for

else:
filename = input('Enter a filename:')

filename = sys.argv[1] if len(sys.argv) == 2 else input('Enter a filename:')
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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


def __contains__(self, name):
return any([s.name == name for s in self._holdings])
return any(s.name == name for s in self._holdings)
Copy link
Author

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

@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)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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


def __contains__(self, name):
return any([s.name == name for s in self._holdings])
return any(s.name == name for s in self._holdings)
Copy link
Author

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

@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)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

record = dict(zip(headers, row))
else:
record = tuple(row)
record = dict(zip(headers, row)) if headers else tuple(row)
Copy link
Author

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

def csv_record(fields):
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)
Copy link
Author

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 only used once

ghreat pushed a commit that referenced this pull request Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant