Skip to content

Sourcery refactored master branch#1

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

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

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Sep 18, 2023

Copy link
Copy Markdown

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^

Help us improve this pull request!

@sourcery-ai
sourcery-ai Bot requested a review from VolubleRain1 September 18, 2023 03:32

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -19 to +23
principal = principal - extra_payment
principal -= extra_payment
total_paid = total_paid + extra_payment

print(month, round(total_paid,2), round(principal, 2))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 19-23 refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Comment thread Solutions/1_33/pcost.py
else:
filename = input('Enter a filename:')

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

Copy link
Copy Markdown
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:

Comment thread Solutions/1_5/bounce.py
Comment on lines -4 to -8
bounce = 1
while bounce <= 10:
for bounce in range(1, 11):
height = height * (3/5)
print(bounce, round(height, 4))
bounce += 1

Copy link
Copy Markdown
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:

Comment thread Solutions/2_16/pcost.py
else:
filename = input('Enter a filename:')

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

Copy link
Copy Markdown
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:

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

Copy link
Copy Markdown
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:

Comment thread Solutions/3_18/report.py
def main(args):
if len(args) != 3:
raise SystemExit('Usage: %s portfile pricefile' % args[0])
raise SystemExit(f'Usage: {args[0]} portfile pricefile')

Copy link
Copy Markdown
Author

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:

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

Copy link
Copy Markdown
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:

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

Copy link
Copy Markdown
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:

Comment thread Solutions/4_10/pcost.py
'''
portfolio = report.read_portfolio(filename)
return sum([s.cost() for s in portfolio])
return sum(s.cost() for s in portfolio)

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/4_10/pcost.py
def main(args):
if len(args) != 2:
raise SystemExit('Usage: %s portfoliofile' % args[0])
raise SystemExit(f'Usage: {args[0]} portfoliofile')

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/4_10/report.py

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 ]

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/4_10/report.py
Comment on lines -66 to +65
raise SystemExit('Usage: %s portfile pricefile format' % args[0])
raise SystemExit(f'Usage: {args[0]} portfile pricefile format')

Copy link
Copy Markdown
Author

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:

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

Copy link
Copy Markdown
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:

Comment thread Solutions/4_4/pcost.py
'''
portfolio = report.read_portfolio(filename)
return sum([s.cost() for s in portfolio])
return sum(s.cost() for s in portfolio)

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/4_4/pcost.py
def main(args):
if len(args) != 2:
raise SystemExit('Usage: %s portfoliofile' % args[0])
raise SystemExit(f'Usage: {args[0]} portfoliofile')

Copy link
Copy Markdown
Author

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:

@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
Copy Markdown
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:

Comment thread Solutions/6_12/report.py
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')

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/6_12/ticker.py
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')

Copy link
Copy Markdown
Author

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:

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

Copy link
Copy Markdown
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:

Comment thread Solutions/6_15/pcost.py
def main(args):
if len(args) != 2:
raise SystemExit('Usage: %s portfoliofile' % args[0])
raise SystemExit(f'Usage: {args[0]} portfoliofile')

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/6_15/report.py
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')

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/6_15/ticker.py
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')

Copy link
Copy Markdown
Author

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:

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

Copy link
Copy Markdown
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:

Comment thread Solutions/6_3/pcost.py
def main(args):
if len(args) != 2:
raise SystemExit('Usage: %s portfoliofile' % args[0])
raise SystemExit(f'Usage: {args[0]} portfoliofile')

Copy link
Copy Markdown
Author

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:


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
Copy Markdown
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:

Comment thread Solutions/7_11/ticker.py
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')

Copy link
Copy Markdown
Author

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:


def typedproperty(name, expected_type):
private_name = '_' + name
private_name = f'_{name}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function typedproperty refactored with the following changes:

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

Copy link
Copy Markdown
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:

Comment thread Solutions/7_4/pcost.py
def main(args):
if len(args) != 2:
raise SystemExit('Usage: %s portfoliofile' % args[0])
raise SystemExit(f'Usage: {args[0]} portfoliofile')

Copy link
Copy Markdown
Author

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:

Comment thread Solutions/7_4/report.py
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')

Copy link
Copy Markdown
Author

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:

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.

0 participants