Skip to content

PosixUPath and WindowsUPath pathlib backport #472

Description

@ap--

PosixUPath and WindowsUPath are UPath subclasses and should adhere to the newest (3.14) pathlib interface. That means we have to backport the changes from newer pathlibs. Changes can basically be separated into changes to the class interface, changes to the method signatures, and changes in behaviour.

Current UPath supports 3.9+, so until we drop 3.9 we have to support it as a base.

The initial solution should backport interface and signature changes. It's probably not worth backporting behaviour. We'll wait for users actually reporting issues for that.

interface changes

py name change consider
3.13+ UnsupportedOperation subclasses NotImplemented

Path

interface changes

these are all in place

py name change
3.10+ .hardlink_to() new method
3.12+ .walk() new method
3.12+ .with_segments() new method
3.12+ .is_junction() new method
3.13+ .full_match() new method
3.13+ .from_uri() new classmethod
3.13+ .parser new attribute
3.14+ .info new attribute
3.14+ .copy new method
3.14+ .copy_into new method
3.14+ .move new method
3.14+ .move_into new method

signature changes

these need to be backported (the exception related ones can possibly be skipped)

py name change
3.10+ .parents supports slices and negative indices ⚠️
3.10+ .stat() follow_symlinks kw
3.10+ .write_text() newline kw
3.10+ .chmod() follow_symlinks kw
3.12+ .match() pattern accepts PathLike, case_sensitive
3.12+ .exists() follow_symlinks kw
3.12+ .glob case_sensitive
3.12+ .rglob case_sensitive
3.12+ .relative_to() walk_up kw
3.13+ .is_file() follow_symlinks kw
3.13+ .is_dir() follow_symlinks kw
3.13+ .read_text() newline kw
3.13+ .glob recurse_symlinks kw, PathLike patterns
3.13+ .rglob recurse_symlinks kw, PathLike patterns
3.13+ .owner() follow_symlinks kw
3.13+ .group() follow_symlinks kw
3.13+ .resolve() symlink loops raise OSError in strict mode instead of RuntimeError ⚠️
3.13+ .readlink() raises UnsupportedOperation instead of NotImplementedError
3.13+ PosixPath raises UnsupportedOperation on Windows instead of NotImplementedError
3.13+ WindowsPath raises UnsupportedOperation on non-Windows instead of NotImplementedError
3.13+ .hardlink_to() raises UnsupportedOperation instead of NotImplementedError
3.13+ .symlink_to() raises UnsupportedOperation instead of NotImplementedError

⚠️ these have not been backported.

behavior changes

will skip for now...

py name change
3.11+ .glob .rglob trailing slash pattern returns dir only
3.12+ .is_mount() windows support
3.13+ .is_reserved() windows path names with colon/dot/space, UNC paths
3.13+ .glob .rglob '**' ending pattern returns files and dirs, OSError suppression
3.14+ .suffix single dot is valid suffix
3.14+ .suffixes single dot is valid suffix
3.14+ .with_suffix() single dot is valid suffix
3.14+ exists(), is_dir() etc return False instead of raising OSError
3.14+ .from_uri() localhost is discarded, authority handling changed

deprecations

also not worth doing right now...

py name change
3.12+ .is_relative_to() passing additional args (removed in 3.14)
3.12+ .relative_to() passing additional args (removed in 3.14)
3.13+ .is_reserved() deprecated (will be removed in 3.15) ☑️
3.14+ .as_uri() deprecated from PurePath (will be removed in 3.19) ☑️

☑️ not needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't workingcompatibility 🤝Compatibility with stdlib pathlib

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions