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

Support inferred values when linting sys path - saved #1863

Closed

Conversation

ericvergnaud
Copy link
Contributor

Changes

Infer value of sys.path.xxx() calls and raise advice if unresolved

Linked issues

Progresses #1205

Functionality

  • added relevant user documentation
  • added new CLI command
  • modified existing command: databricks labs ucx ...
  • added a new workflow
  • modified existing workflow: ...
  • added a new table
  • modified existing table: ...

Tests

  • manually tested
  • added unit tests
  • added integration tests
  • verified on staging environment (screenshot attached)

@ericvergnaud ericvergnaud requested review from a team and dleiva04 June 7, 2024 17:21
elif isinstance(base_node, ImportSource):
yield from self._register_import(base_node)
else:
logger.error(f"Can't process {NodeBase.__name__} of type {type(base_node).__name__}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
logger.error(f"Can't process {NodeBase.__name__} of type {type(base_node).__name__}")
logger.warning(f"Can't process {NodeBase.__name__} of type {type(base_node).__name__}")

Error logs fail the workflow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


def _visit_inferred(self, changed: NodeNG, inferred: NodeNG, is_relative: bool, is_append: bool):
if inferred is Uninferable or not isinstance(inferred, Const):
self.sys_path_changes.append(UnresolvedPath(changed, changed.as_string(), is_append))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.sys_path_changes.append(UnresolvedPath(changed, changed.as_string(), is_append))
self.sys_path_changes.append(UnresolvedPath(changed, changed.as_string(), is_append))
return

Can we explicitly return, so that branches won't fall through accidentally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ericvergnaud
Copy link
Contributor Author

@nfx I'll rebase once #1860 is merged

@ericvergnaud ericvergnaud requested a review from nfx June 8, 2024 10:33
@ericvergnaud ericvergnaud deleted the support-inferred-values-when-linting-sys-path branch June 9, 2024 16:56
@ericvergnaud ericvergnaud changed the title Support inferred values when linting sys path Support inferred values when linting sys path - saved Jun 9, 2024
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