Skip to content

Commit 90b0a09

Browse files
authored
Fix incorrect import (#1851)
## Changes Fix incorrect import ### Linked issues None ### 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) Co-authored-by: Eric Vergnaud <[email protected]>
1 parent f346f0a commit 90b0a09

File tree

1 file changed

+4
-2
lines changed
  • src/databricks/labs/ucx/source_code

1 file changed

+4
-2
lines changed

src/databricks/labs/ucx/source_code/graph.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import annotations
22

33
import abc
4-
import ast
54
from dataclasses import dataclass
65
from pathlib import Path
76
from collections.abc import Callable
87
from typing import cast
8+
from astroid import ImportFrom # type: ignore
99

1010
from databricks.labs.ucx.source_code.base import Advisory
1111
from databricks.labs.ucx.source_code.linters.imports import (
@@ -192,7 +192,9 @@ def _process_node(self, base_node: NodeBase):
192192
else:
193193
yield from self.register_notebook(Path(strpath))
194194
if isinstance(base_node, ImportSource):
195-
prefix = ("." * base_node.node.level) if isinstance(base_node.node, ast.ImportFrom) else ""
195+
prefix = ""
196+
if isinstance(base_node.node, ImportFrom) and base_node.node.level is not None:
197+
prefix = "." * base_node.node.level
196198
name = base_node.name or ""
197199
yield from self.register_import(prefix + name)
198200

0 commit comments

Comments
 (0)