Skip to content

Commit 901282c

Browse files
authored
Fix incorrect glob docstring for '[!]' (empty negated class) (#2084)
1 parent 918451a commit 901282c

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎fsspec/spec.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,7 @@ def glob(self, path, maxdepth=None, **kwargs):
635635
Special behaviors:
636636
- If the path ends with '/', only folders are returned
637637
- Consecutive '*' characters are compressed into a single '*'
638-
- Empty brackets '[]' never match anything
639-
- Negated empty brackets '[!]' match any single character
638+
- Empty set '[]' or negated empty negated set '[!]' never match anything
640639
- Special characters in character classes are escaped properly
641640
642641
Limitations:

‎fsspec/tests/test_spec.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@
6363
"argnames": ("path", "expected"),
6464
"argvalues": [
6565
("nonexistent", []),
66+
# bare "[!]" is the literal string "[!]" (an empty negated class),
67+
# and "[]" is an empty class; neither matches anything -- matching
68+
# Python's glob/fnmatch and bash. See glob() docstring.
69+
("test0/[!]", []),
70+
("[]", []),
71+
("test[]0.json", []),
6672
("test0.json", ["test0.json"]),
6773
("test0", ["test0"]),
6874
("test0/", ["test0"]),

0 commit comments

Comments
 (0)