-
Couldn't load subscription status.
- Fork 1
Sourcery Starbot ⭐ refactored haolly/dependency-resolver #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
base: main
Are you sure you want to change the base?
Conversation
| if not vtx in self.dummy_traversing_edges: | ||
| if vtx not in self.dummy_traversing_edges: | ||
| self.dummy_traversing_edges[vtx] = {} | ||
|
|
||
| if not child_vtx in self.dummy_traversing_edges[vtx]: | ||
| if child_vtx not in self.dummy_traversing_edges[vtx]: |
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 Layering.proper_layering refactored with the following changes:
- Simplify logical expression using De Morgan identities [×2] (
de-morgan)
| resp = "" | ||
| for layer in self.__layers: | ||
| resp += str(layer.level) + " => " + str(layer.nodes) + "\n" | ||
| return resp | ||
| return "".join( | ||
| f"{str(layer.level)} => {str(layer.nodes)}" + "\n" | ||
| for layer in self.__layers | ||
| ) |
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 Layering.__str__ refactored with the following changes:
- Use str.join() instead of for loop (
use-join) - Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| fps = 0 | ||
| if self.dt: fps = 1/self.dt | ||
| fps = 1/self.dt if self.dt else 0 | ||
| if len(self.fps_list) == 50: | ||
| self.fps_list.pop(0) | ||
| self.fps_list.append(fps) | ||
| avg_fps = sum(self.fps_list) / len(self.fps_list) | ||
| pygame.display.set_caption('Dependency resolver - FPS: ' + str(round(avg_fps,2))) | ||
| pygame.display.set_caption( | ||
| f'Dependency resolver - FPS: {str(round(avg_fps, 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.
Function Resolver.get_fps refactored with the following changes:
- Move setting of default value for variable into
elsebranch (introduce-default-else) - Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Replace if statement with if expression (
assign-if-exp)
| for i, ext in enumerate(self.SUPPORTED_FILES): | ||
| if filename.endswith(ext): | ||
| return i | ||
|
|
||
| return -1 | ||
| return next( | ||
| ( | ||
| i | ||
| for i, ext in enumerate(self.SUPPORTED_FILES) | ||
| if filename.endswith(ext) | ||
| ), | ||
| -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 DependencyScanner.is_valid_project_file refactored with the following changes:
- Use the built-in function
nextinstead of a for-loop (use-next)
|
|
||
| # Report progress to the caller | ||
| if self.__progress_cb: | ||
| self.__progress_cb(i, len(project_files), file.replace(path_dir, "")) | ||
|
|
||
| includes = self.get_includes(file) | ||
| dep_map[file] = includes | ||
| self.glob_log.info(f"Scan complete!") | ||
|
|
||
| self.glob_log.info("Scan complete!") |
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 DependencyScanner.scan_dir refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
| if not u in self._adj_nodes[v]: | ||
| if u not in self._adj_nodes[v]: |
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 GraphAdjList.reverse_edge refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
| target_project_dir = self.resolver.find_directory() | ||
|
|
||
| if target_project_dir: | ||
| if target_project_dir := self.resolver.find_directory(): | ||
| new_state = Scan(self.resolver, target_project_dir) | ||
| new_state.enter_state() | ||
| else: | ||
| self.resolver.show_error("Project directory", "You haven't selected a project directory.") | ||
|
|
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 Menu.update refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
|
|
||
| # prevent files with improper includes or "self includes" | ||
| if not included_file == source_file: | ||
| if included_file != source_file: |
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 Scan.__prepare_and_sort_dag refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
|
|
||
| if (node_id, vtx_out) in self.reversed_edges: | ||
| if not node_id in self.digraph.get_neighbors_out(vtx_out): | ||
| if node_id not in self.digraph.get_neighbors_out(vtx_out): |
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 World.render_nodes refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
| self.state = ClickableState.HOVERED | ||
| if is_clicked: | ||
| self.state = ClickableState.CLICKED | ||
| self.state = ClickableState.CLICKED if is_clicked else ClickableState.HOVERED |
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 Button.update refactored with the following changes:
- Move setting of default value for variable into
elsebranch (introduce-default-else) - Replace if statement with if expression (
assign-if-exp)
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
mainbranch, then run: