canonical / canonical/charmlibs
Investigate supporting newer pathlib.Path.match features
- Dominant language
- Python
- Stars
- 5
- Forks
- 28
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 24
Description
Python 3.12 added support for `pathlib.Path.match` to accept a path-like object instead of just a string. Python 3.14 subtly adjusted the behaviour to also work for any object that implements `with_segments`, even if it isn't path-like.
Python 3.13 added the related method `pathlib.Path.full_match`.
We should investigate which (if any) of these changes `charmlibs.pathops` could (and should) support now, and clearly document when we should add support for other features.
The `match` behaviour change on Python 3.14 prompted the creation of this issue, as a `ContainerPath` will now be accepted at runtime by `pathlib.PurePath.match`, `LocalPath.match`, and `ContainerPath.match`. At the very least, `ContainerPath.match` should probably return `False` if the containers don't match, if not make it an error to use `ContainerPath` here since it isn't `os.PathLike`.
---
Python 3.12's `match` features are added in #524.
Python 3.13's `full_match` won't be backported, and will only be supported once the library's minimum Python version is high enough (see #567).
Contributor guide
Assessment
This issue has not been assessed yet.