Skip to content
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

Sourcery Starbot ⭐ refactored haolly/dependency-resolver #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SourceryAI
Copy link

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 main branch, then run:

git fetch https://github.com/sourcery-ai-bot/dependency-resolver main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -60 to +63
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]:
Copy link
Author

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)

Comment on lines -75 to +78
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
)
Copy link
Author

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:

Comment on lines -129 to +136
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))}'
)
Copy link
Author

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:

Comment on lines -25 to +32
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,
)
Copy link
Author

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 next instead of a for-loop (use-next)

Comment on lines -73 to +84

# 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!")
Copy link
Author

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:

Comment on lines -136 to +155
if not u in self._adj_nodes[v]:
if u not in self._adj_nodes[v]:
Copy link
Author

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)

Comment on lines -53 to +58
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.")

Copy link
Author

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:

if not included_file == source_file:
if included_file != source_file:
Copy link
Author

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 not node_id in self.digraph.get_neighbors_out(vtx_out):
if node_id not in self.digraph.get_neighbors_out(vtx_out):
Copy link
Author

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

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:

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