Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 2, 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^

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

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 {TOTAL_COMMENTS_PER_REVIEW} comments can be shown.

loglevel = log_levels[level]
else:
loglevel = log_levels['3']
loglevel = log_levels.get(level, log_levels['3'])
Copy link
Author

Choose a reason for hiding this comment

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

Function setup_logging refactored with the following changes:

  • Simplify dictionary access using default get

Comment on lines -112 to -120
if type(s) is unicode:
if type(s) is unicode or type(s) is not str:
return s
elif type(s) is str:
else:
try:
return unicode(s, term_encoding)
except ValueError:
logger.error('s2or3 exception: {0}'.format(s))
else:
return s
Copy link
Author

Choose a reason for hiding this comment

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

Function s2or3 refactored with the following changes:

  • Merge duplicate blocks in conditional
  • Remove redundant conditional

Comment on lines -495 to +492
if s.upper() == s and s.lower() != s:
shift = "Shift-"
else:
shift = ""
if mac:
# return "{0}Cmd-{1}".format(shift, s), "<{0}Command-{1}>".format(shift, s)
return "{0}Ctrl-{1}".format(shift, s.upper()), "<{0}Control-{1}>".format(shift, s)
else:
return "{0}Ctrl-{1}".format(shift, s.upper()), "<{0}Control-{1}>".format(shift, s)
shift = "Shift-" if s.upper() == s and s.lower() != s else ""
# return "{0}Cmd-{1}".format(shift, s), "<{0}Command-{1}>".format(shift, s)
return "{0}Ctrl-{1}".format(shift, s.upper()), "<{0}Control-{1}>".format(shift, s)
Copy link
Author

Choose a reason for hiding this comment

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

Function commandShortcut refactored with the following changes:

  • Hoist repeated code outside conditional statement
  • Replace if statement with if expression

Comment on lines -511 to +500
if s.upper() == s and s.lower() != s:
shift = "Shift-"
else:
shift = ""
shift = "Shift-" if s.upper() == s and s.lower() != s else ""
Copy link
Author

Choose a reason for hiding this comment

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

Function optionShortcut refactored with the following changes:

  • Replace if statement with if expression

Comment on lines -543 to +529
if dn > 1:
days = dn - 1
else:
days = 0
days = dn - 1 if dn > 1 else 0
Copy link
Author

Choose a reason for hiding this comment

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

Function get_week refactored with the following changes:

  • Inline variable that is only used once
  • Replace if statement with if expression

Comment on lines -1934 to +1921
Checkbutton(self.win, text=self.options[i][0], padx=20, variable=self.check_values[i]).pack(padx=10, anchor=W)
Checkbutton(
self.win, text=txt, padx=20, variable=self.check_values[i]
).pack(padx=10, anchor=W)

Copy link
Author

Choose a reason for hiding this comment

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

Function OptionsDialog.__init__ refactored with the following changes:

  • Swap positions of nested conditionals
  • Hoist repeated code outside conditional statement
  • Use previously assigned local variable

Comment on lines +1099 to -1105
width0 = self.tree.column('#0')['width']
if self.labels:
width0 = self.tree.column('#0')['width']
self.tree.column('#0', width=width0 + self.col2_width)
self.tree.column('#1', width=0)
self.labels = False
else:
width0 = self.tree.column('#0')['width']
Copy link
Author

Choose a reason for hiding this comment

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

Function App.toggleLabels refactored with the following changes:

  • Hoist repeated code outside conditional statement

Comment on lines -1176 to +1175
if self.weekly or self.monthly:
master = self.canvas
else:
master = self.tree

master = self.canvas if self.weekly or self.monthly else self.tree
Copy link
Author

Choose a reason for hiding this comment

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

Function App.selectCalendars refactored with the following changes:

  • Replace if statement with if expression

Comment on lines -1239 to +1234
if mac:
cmd = 'open' + " {0}".format(path)
else:
cmd = 'xdg-open' + " {0}".format(path)
cmd = 'open' + " {0}".format(path) if mac else 'xdg-open' + " {0}".format(path)
Copy link
Author

Choose a reason for hiding this comment

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

Function App.openWithDefault refactored with the following changes:

  • Replace if statement with if expression

Comment on lines -1253 to +1250
return
else:
cmd = "lp -s -o media='letter' -o cpi=12 -o lpi=8 -o page-left=48 -o page-right=48 -o page-top=48 -o page-bottom=48 {0}\n".format(loop.tmpfile)
# cmd = "lpr -l {0}".format(loop.tmpfile)
self.check_output(cmd)
return

return
Copy link
Author

Choose a reason for hiding this comment

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

Function App.printWithDefault refactored with the following changes:

  • Hoist repeated code outside conditional statement

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.

2 participants