-
Notifications
You must be signed in to change notification settings - Fork 115
Sourcery Starbot ⭐ refactored akkana/scripts #11
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
base: master
Are you sure you want to change the base?
Conversation
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.
Due to GitHub API limits, only the first 60 comments can be shown.
| if self.lunar: | ||
| self.sun = ephem.Moon() | ||
| else: | ||
| self.sun = ephem.Sun() | ||
| self.sun = ephem.Moon() if self.lunar else ephem.Sun() | ||
| self.sinusoidal = False | ||
|
|
||
| self.sun_color = (1, 1, 0) | ||
| self.backside_color = (1, .7, 0) | ||
| self.text_color = (1, 1, 0) | ||
| if background: | ||
| self.background_color = background | ||
| else: | ||
| self.background_color = (0, 0, .6, 1) | ||
| self.background_color = background if background else (0, 0, .6, 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.
Function AnalemmaWindow.__init__ refactored with the following changes:
- Replace if statement with if expression
| for f in range(0, int(math.pi * 100)): | ||
| for f in range(int(math.pi * 100)): |
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 AnalemmaWindow.draw refactored with the following changes:
- Replace range(0, x) with range(x)
- Replace unused for index with underscore
| lenpath = len(path) | ||
| if recursive: | ||
| file_list = [] | ||
| lenpath = len(path) |
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 list_local_dir refactored with the following changes:
- Move assignments closer to their usage
| If move=True, use move rather than copy (remove the src). | ||
| """ | ||
| if not is_android(src) and not is_android(dst): | ||
| if not (is_android(src) or is_android(dst)): |
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 copyfile refactored with the following changes:
- Simplify logical expression
| if os.path.basename(p[0]) == base: | ||
| if p[1] == pair[1]: | ||
| match = i | ||
| num_matches += 1 | ||
| if os.path.basename(p[0]) == base and p[1] == pair[1]: | ||
| match = i | ||
| num_matches += 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.
Function find_basename_size_match refactored with the following changes:
- Merge nested if conditions
| if hour > 12: | ||
| hourstr = str(hour-12) + " pm" | ||
| else: | ||
| hourstr = str(hour) + " am" | ||
|
|
||
| hourstr = str(hour-12) + " pm" if hour > 12 else str(hour) + " am" |
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 Conjunction.closeout.conjstr refactored with the following changes:
- Replace if statement with if expression
| if transit[3] < 3 or transit[3] > 12: | ||
| when = "evening" | ||
| else: | ||
| when = "morning" | ||
|
|
||
| if p == "Venus" or p == "Mercury": | ||
| when = "evening" if transit[3] < 3 or transit[3] > 12 else "morning" | ||
| if p in ["Venus", "Mercury"]: |
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 finish_planet refactored with the following changes:
- Replace if statement with if expression
- Replace multiple comparisons of same variable with
inoperator - Simplify conditional into switch-like form
- Split conditional into multiple branches
- Merge duplicate blocks in conditional
- Remove redundant conditional
- Remove empty elif clause
- Simplify logical expression
| minsyl += 1 | ||
| maxsyl += 1 | ||
| elif on_vowel and not in_diphthong and c != lastchar: | ||
| elif not in_diphthong and c != lastchar: |
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 count_syllables refactored with the following changes:
- Remove redundant conditional
| else: | ||
| ret += part[0] | ||
|
|
||
| ret += part[0].decode(errors='replace') if type(part[0]) is bytes else part[0] |
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 decode_piece refactored with the following changes:
- Replace if statement with if expression
| if sys.argv[1] == '-h' or sys.argv[1] == '--help': | ||
| if sys.argv[1] in ['-h', '--help']: |
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 162-162 refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator
| for i in range(RETRIES): | ||
| for _ in range(RETRIES): | ||
| try: | ||
| domain = whois.whois(name) | ||
| return domain | ||
| return whois.whois(name) |
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 get_domain refactored with the following changes:
- Inline variable that is only used once
- Replace unused for index with underscore
| if d[1] < two_months_from_now: | ||
| alert = "***" | ||
| else: | ||
| alert = "" | ||
| alert = "***" if d[1] < two_months_from_now else "" |
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 66-69 refactored with the following changes:
- Replace if statement with if expression
| else: | ||
| message = "Wake up!" | ||
|
|
||
| message = ' '.join(sys.argv[2:]) if len(sys.argv) > 2 else "Wake up!" |
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 68-72 refactored with the following changes:
- Replace if statement with if expression
| return | ||
|
|
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 EpubBook.parse_contents refactored with the following changes:
- Remove unreachable code
| if len(authors) > 1: | ||
| outstr += "Authors: " | ||
| else: | ||
| outstr += "Author: " | ||
| outstr += "Authors: " if len(authors) > 1 else "Author: " |
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 EpubBook.info_string refactored with the following changes:
- Replace if statement with if expression
| if pat in tags: | ||
| return True | ||
| return False | ||
| return any(pat in tags for pat in orpats) |
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 has_match refactored with the following changes:
- Use any() instead of for loop
| legend_patches = [] | ||
| for c in colormap: | ||
| legend_patches.append(mpatches.Patch(color=colormap[c], label=c)) | ||
| legend_patches = [mpatches.Patch(color=colormap[c], label=c) for c in colormap] |
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 53-55 refactored with the following changes:
- Convert for loop into list comprehension
|
|
||
| for branch in localbranches: | ||
| lb = localbranches[branch] | ||
| for branch, lb in localbranches.items(): |
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 list_branches refactored with the following changes:
- Use items() to directly unpack dictionary values
| if not args.list and not args.check and not args.track: | ||
| if not (args.list or args.check or args.track): |
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 main refactored with the following changes:
- Simplify logical expression
| def zoom_hundred_cb(self, menu_item, web_view): | ||
| """Zoom 100%""" | ||
| if not (web_view.get_zoom_level() == 1.0): | ||
| if web_view.get_zoom_level() != 1.0: |
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 WebToolbar.zoom_hundred_cb refactored with the following changes:
- Simplify logical expression
| tcrit = piece.critical | ||
|
|
||
| if not tcurrent or (not tmax and not tcrit): | ||
| if not (tcurrent and (tmax or tcrit)): |
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 fetch_temps refactored with the following changes:
- Simplify logical expression
| if quad[1] > quad[2]: | ||
| return True | ||
| return False | ||
| return any(quad[1] > quad[2] for quad in temps) |
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 overtemp refactored with the following changes:
- Use any() instead of for loop
|
|
||
| def contains_non_ascii_characters(s): | ||
| return not all(ord(c) < 128 for c in s) | ||
| return any(ord(c) >= 128 for c in s) |
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 contains_non_ascii_characters refactored with the following changes:
- Simplify inverted any() and all() calls
| imagewin.next_image() | ||
| return | ||
| if event.string == "q": | ||
| elif event.string == "q": |
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 key_press_event refactored with the following changes:
- Simplify conditional into switch-like form
| if True: | ||
| rect = self.get_allocation() | ||
| w = rect.width | ||
| h = rect.height | ||
| if w != self.width or h != self.height: | ||
| # get_allocation() gives a number that's too large, | ||
| # and if we later try to draw_rectangle() with these | ||
| # dimensions, we'll only get half the rectangle horizontally. | ||
| # I have no idea why this is happening, but subtracting a | ||
| # few pixels from allocation width is a temporary workaround. | ||
| self.width = w # -5 | ||
| self.height = h | ||
|
|
||
| # Have we had load_image called, but we weren't ready for it? | ||
| # Now, theoretically, we are ... so call it again. | ||
| if w and h and self.cur_img and not self.pixbuf: | ||
| self.prepare_image() | ||
| rect = self.get_allocation() | ||
| w = rect.width | ||
| h = rect.height | ||
| if w != self.width or h != self.height: | ||
| # get_allocation() gives a number that's too large, | ||
| # and if we later try to draw_rectangle() with these | ||
| # dimensions, we'll only get half the rectangle horizontally. | ||
| # I have no idea why this is happening, but subtracting a | ||
| # few pixels from allocation width is a temporary workaround. | ||
| self.width = w # -5 | ||
| self.height = h | ||
|
|
||
| # Have we had load_image called, but we weren't ready for it? | ||
| # Now, theoretically, we are ... so call it again. | ||
| if w and h and self.cur_img and not self.pixbuf: | ||
| self.prepare_image() |
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 ImageViewer.draw refactored with the following changes:
- Remove redundant conditional
| the next one. | ||
| """ | ||
| if e.key == 'ctrl+q' or e.key == 'q': | ||
| if e.key in ['ctrl+q', 'q']: |
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 key_press refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator
| if mname in self.mon_geom: | ||
| active.append(mname) | ||
| return active | ||
| return [mname for mname in self.monitors if mname in self.mon_geom] |
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 MonMon.active_monitors refactored with the following changes:
- Convert for loop into list comprehension
- Inline variable that is only used once
| inactive = [] | ||
| for mname in self.monitors: | ||
| if mname not in self.mon_geom: | ||
| inactive.append(mname) | ||
| return inactive | ||
| return [mname for mname in self.monitors if mname not in self.mon_geom] |
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 MonMon.inactive_monitors refactored with the following changes:
- Convert for loop into list comprehension
- Inline variable that is only used once
| if self.laptop_screen == mon['name']: | ||
| islaptop = " **laptop" | ||
| else: | ||
| islaptop = "" | ||
| islaptop = " **laptop" if self.laptop_screen == mon['name'] else "" |
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 MonMon.print_monitor refactored with the following changes:
- Replace if statement with if expression
| if start <= end: | ||
| return list(range(start, end)) | ||
| return list(range(start, max)) + list(range(0, end)) | ||
| return list(range(start, max)) + list(range(end)) |
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 discont_range refactored with the following changes:
- Replace range(0, x) with range(x)
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
masterbranch, then run: