universal_pathlib icon indicating copy to clipboard operation
universal_pathlib copied to clipboard

Provide a better way to allow static type-narrowing for the UPath constructor

Open ap-- opened this issue 5 months ago • 1 comments

Currently it seems all python type-checkers seem to have some limitation regarding either __new__ overloads or type.__call__ overloads.

see: #435

This issue tracks if we can come up with a better way to overload the constructor thats supported by all typecheckers.

xref / blocked-by:

  • astral-sh/ty#281
  • python/mypy#15182
  • python/mypy#17251

ap-- avatar Oct 08 '25 20:10 ap--

There are two ways right now to get IDE autocompletion and suggestions for storage_options:

  1. use the correct upath subclass directly Image

  2. use upath.registry.get_upath_class to narrow to the right class on protocol Image

ap-- avatar Oct 16 '25 12:10 ap--