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

Remove redundant if-condition in the GraphWalker._iter_one #3654

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/databricks/labs/ucx/source_code/linters/graph_walkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ def _iter_one(self, dependency: Dependency, graph: DependencyGraph, root_path: P
self._lineage.append(dependency)
self._walked_paths.add(dependency.path)
self._log_walk_one(dependency)
if dependency.path.is_file() or is_a_notebook(dependency.path):
Copy link
Member Author

Choose a reason for hiding this comment

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

@pritishpai and @asnare : This is another if-condition in this method about which I am unsure. However, I want to remove it as it is interfering with surfacing known problems during linting.

Notes:

  • Removing the if-condition does not let any unit test fail
  • The condition was introduced without notes, explanation or questions
  • IMO the base graph walker class should not decide to skip a dependency. Classes that inherit form this class can decide to skip specific dependencies
  • I introduced a new dependency to surface known problems, KnownDependency, which is not processed as the condition is not true for that dependency. Instead of extending the condition, I think it should be removed all together

inherited_tree = graph.root.build_inherited_tree(root_path, dependency.path)
path_lookup = self._path_lookup.change_directory(dependency.path.parent)
yield from self._process_dependency(dependency, path_lookup, inherited_tree)
maybe_graph = graph.locate_dependency(dependency.path)
# missing graph problems have already been reported while building the graph
if maybe_graph.graph:
child_graph = maybe_graph.graph
for child_dependency in child_graph.local_dependencies:
yield from self._iter_one(child_dependency, child_graph, root_path)
inherited_tree = graph.root.build_inherited_tree(root_path, dependency.path)
path_lookup = self._path_lookup.change_directory(dependency.path.parent)
yield from self._process_dependency(dependency, path_lookup, inherited_tree)
maybe_graph = graph.locate_dependency(dependency.path)
# missing graph problems have already been reported while building the graph
if maybe_graph.graph:
child_graph = maybe_graph.graph
for child_dependency in child_graph.local_dependencies:
yield from self._iter_one(child_dependency, child_graph, root_path)
self._lineage.pop()

def _log_walk_one(self, dependency: Dependency) -> None:
Expand Down