Skip to content

Commit f68ee99

Browse files
ericvergnaudEric Vergnaud
andauthored
fix issue 1564 (#1567)
also fix missing WorkspacePath equality ## Changes fixed WorkspacePath ### Linked issues Resolves #1564 ### 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 - [x] fixed failing integration tests - [ ] verified on staging environment (screenshot attached) --------- Co-authored-by: Eric Vergnaud <[email protected]>
1 parent 18b005b commit f68ee99

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/databricks/labs/ucx/mixins/wspath.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ def __from_raw_parts(this, ws: WorkspaceClient, flavour: _DatabricksFlavour, drv
179179
def _make_child_relpath(self, part):
180180
# used in dir walking
181181
path = self._flavour.join(self._parts + [part])
182+
# self._flavour.join duplicates leading '/' (possibly a python bug)
183+
# but we can't override join in _DatabricksFlavour because it's built-in
184+
# and if we remove the leading '/' part then we don't get any
185+
# so let's just do a slow but safe sanity check afterward
186+
if os.sep == path[0] == path[1]:
187+
path = path[1:]
182188
return WorkspacePath(self._ws, path)
183189

184190
def _parse_args(self, args): # pylint: disable=arguments-differ
@@ -314,3 +320,9 @@ def is_file(self):
314320

315321
def is_notebook(self):
316322
return self._object_info.object_type == ObjectType.NOTEBOOK
323+
324+
def __eq__(self, other):
325+
return isinstance(other, Path) and self.as_posix() == other.as_posix()
326+
327+
def __hash__(self):
328+
return Path.__hash__(self)

0 commit comments

Comments
 (0)