fix(dbutils): accept pathlib.Path arguments in fs methods#1461
fix(dbutils): accept pathlib.Path arguments in fs methods#1461nileshpatil6 wants to merge 3 commits into
Conversation
DBUtils fs methods only accepted string paths, raising an error when pathlib.Path objects were passed. Since Path is the standard way to handle paths in modern Python, convert Path to str at method entry via a small _as_str helper. Fixes databricks#1459 Signed-off-by: nileshpatil6 <technil6436@gmail.com>
Signed-off-by: nileshpatil6 <technil6436@gmail.com>
|
@nileshpatil6 any updates here? |
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
|
Hey, sorry for the delay. The branch had gone stale, upstream removed NEXT_CHANGELOG.md (and its workflow) in the v0.117.0 release, which is what caused the merge conflict. I've merged the latest main and dropped the changelog hunk since that whole mechanism is gone now. The diff is back to just the two files: dbutils.py and its tests. Reran the full tests/test_dbutils.py suite locally, 26/26 pass, and ruff format/lint (pinned 0.5.6) are clean. Worth noting per the updated CONTRIBUTING.md this repo is now a read-only mirror, so even once approved a maintainer re-applies the change internally and it ships with a release rather than merging here directly. |
Fixes #1459
dbutils.fsmethods only accepted plain strings, so passing apathlib.Pathfailed even though Path is idiomatic in modern Python.What changed
Added a small
_as_strhelper indatabricks/sdk/dbutils.pythat converts aPathtostrand leaves strings untouched. Called it at the entry of every_FsUtilmethod that takes a path argument (ls,cp,mv,rm,mkdirs,head,put,mount,unmount,updateMount).Tests
Added 7 unit tests (one per patched method) that pass a
Pathobject and assert the underlying API is still called with a plain string.Signed-off-by: nileshpatil6 technil6436@gmail.com