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

[internal] Simplify import resolvers #1746

Merged
merged 6 commits into from
May 23, 2024
Merged

[internal] Simplify import resolvers #1746

merged 6 commits into from
May 23, 2024

Conversation

ericvergnaud
Copy link
Contributor

@ericvergnaud ericvergnaud commented May 22, 2024

Changes

Remove chain of import resolvers in favor of a single resolver.

Supersedes #1709

Resolves #1707

Copy link

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 91.42857% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 89.64%. Comparing base (47f8784) to head (a7778bd).

Files Patch % Lines
src/databricks/labs/ucx/source_code/files.py 89.28% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1746      +/-   ##
==========================================
- Coverage   89.66%   89.64%   -0.02%     
==========================================
  Files          93       93              
  Lines       11405    11377      -28     
  Branches     2005     2005              
==========================================
- Hits        10226    10199      -27     
+ Misses        794      793       -1     
  Partials      385      385              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@nfx nfx left a comment

Choose a reason for hiding this comment

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

simplify even further.

@@ -277,21 +277,9 @@ def _fail(code: str, message: str) -> MaybeDependency:

class BaseImportResolver(abc.ABC):
Copy link
Collaborator

Choose a reason for hiding this comment

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

redundant: we no longer need BaseImportResolver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's necessary to avoid circular imports (same as BaseNotebookResolver)

@@ -111,13 +112,11 @@ def __repr__(self):

class LocalFileResolver(BaseImportResolver, BaseFileResolver):
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
class LocalFileResolver(BaseImportResolver, BaseFileResolver):
class ImportResolver(BaseFileResolver):

and get rid of BaseImportResolver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to ImportFileResolver

return WhitelistResolver(self._whitelist, resolver)

def resolve_import(self, path_lookup: PathLookup, name: str) -> MaybeDependency:
def resolve_import(self, name: str) -> MaybeDependency | None:
# TODO attach compatibility to dependency, see https://github.com/databrickslabs/ucx/issues/1382
compatibility = self._whitelist.compatibility(name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

move the body of this method as private method to ImportResolver class and get rid of WhitelistResolver.

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

Copy link
Collaborator

@nfx nfx left a comment

Choose a reason for hiding this comment

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

lgtm

@nfx nfx changed the title Simplify import resolvers [internal] Simplify import resolvers May 23, 2024
@nfx nfx merged commit 4ea2b0b into main May 23, 2024
7 of 8 checks passed
@nfx nfx deleted the simplify-import-resolvers branch May 23, 2024 12:06
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.

[BUG]: Linting raises library-not-found problem when import type_extensions
2 participants