drivendataorg / drivendataorg/cloudpathlib

Achieve parity with globbing functionality in Python >= 3.13

Open
#479 0 comments 0 reactions 0 assignees View on GitHub
bug design decision
Dominant language
Python
Stars
628
Forks
88
Avg merge
17h 28m
Merged PRs (30d)
2

Description

There are a few limitations to our current implementation for glob in newer versions of Python. In #474, we introduced `cloupathlib/legacy/glob.py` that has CPython code that was removed in 3.13, but we need for globbing.

This also means that there is no good way to implement parity with the behavior in 3.13 that [globbing with a pattern that ends with “**” returns both files and directories. In previous versions, only directories were returned.](https://docs.python.org/3.13/library/pathlib.html#pattern-language) Our current implementation does not have parity; if you add a test for `path.glob("**")` because Python 3.13 in this instance returns the directory `path` represents and we don't.

We should update our glob implementation in the following ways:
- [ ] Use the new [glob.translate](https://docs.python.org/3/library/glob.html#glob.translate) for our glob implementation if Python version supports it (and maybe even backport).
- [ ] Remove the vendored CPython code in `cloupathlib/legacy/glob.py`
- [ ] Fix the mismatch with patterns ending in `**` discussed above

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.