Skip to content

fix: support CloudPath subclasses in normalize_path and file_browser#8879

Open
BillionClaw wants to merge 1 commit intomarimo-team:mainfrom
BillionClaw:fix/cloudpathlib-subclass-support
Open

fix: support CloudPath subclasses in normalize_path and file_browser#8879
BillionClaw wants to merge 1 commit intomarimo-team:mainfrom
BillionClaw:fix/cloudpathlib-subclass-support

Conversation

@BillionClaw
Copy link
Copy Markdown

Fix: Support CloudPath subclasses in path normalization

Problem

Custom cloudpathlib providers (e.g., SMBPath) that subclass CloudPath were not recognized by marimo's path handling because normalize_path and the file browser used a fragile module-name check:

if path.__class__.__module__.startswith("cloudpathlib"):

This only matched the built-in S3Path, GSPath, AzurePath etc., but not user-created subclasses whose module would be their own package (e.g., mypackage.smbpath).

As a result, os.path.normpath was called on cloud paths, corrupting URI schemes like smb://server/share into smb:/server/share.

Solution

Replace the module-name check with isinstance(path, CloudPath), which correctly identifies all subclasses of CloudPath. The old module-name check is kept as a fallback for backward compatibility.

Changes

  • marimo/_utils/paths.py: normalize_path() now uses isinstance(path, CloudPath) with a try/except ImportError, falling back to the module-name check
  • marimo/_plugins/ui/_impl/file_browser.py: Same isinstance-based check for the cloud storage limit heuristic
  • tests/_utils/test_paths.py: Minor comment update to clarify fallback behavior

Testing

All 15 tests in tests/_utils/test_paths.py pass.

Fixes #8868.

Use isinstance(path, CloudPath) instead of checking __module__ name,
so that custom cloudpathlib providers (e.g., SMBPath) that extend
CloudPath are properly recognized and bypass normalization.

Fixes marimo-team#8868
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Mar 26, 2026 4:47am

Request Review

@github-actions
Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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.

Not possible to use Path extended from cloudpathlib

1 participant