Skip to content

Commit 32c5a5b

Browse files
authored
Fix magic/non-magic mix handling (#206)
* Fix magic/non-magic mix handling Fixes #205 * Fix mypy
1 parent 223f9ca commit 32c5a5b

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

docs/src/markdown/about/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 8.5.1
4+
5+
- **FIX**: Fix handling of current directory when magic and non-magic patterns are mixed in `glob` pattern list.
6+
37
## 8.5
48

59
- **NEW**: Formally support Python 3.11 (no change).

tests/test_glob.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,18 @@ def test_negateall_bytes(self):
10001000
for file in glob.glob(b'!**/', flags=glob.N | glob.NEGATEALL | glob.G, root_dir=os.fsencode(self.tempdir)):
10011001
self.assert_equal(os.path.isdir(file), False)
10021002

1003+
def test_magic_non_magic(self):
1004+
"""Test logic when switching from magic to non-magic patterns."""
1005+
1006+
with change_cwd(self.tempdir):
1007+
self.assert_equal(sorted(glob.glob(['**/aab', 'dummy'], flags=glob.G)), ['aab',])
1008+
1009+
def test_non_magic_magic(self):
1010+
"""Test logic when switching from non-magic to magic patterns."""
1011+
1012+
with change_cwd(self.tempdir):
1013+
self.assert_equal(sorted(glob.glob(['dummy', '**/aab'], flags=glob.G)), ['aab',])
1014+
10031015

10041016
class TestGlobMarked(Testglob):
10051017
"""Test glob marked."""

tests/test_pathlib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ def test_pickle(self):
340340
p3 = pickle.loads(pickle.dumps(p1))
341341
p4 = pickle.loads(pickle.dumps(p2))
342342

343-
self.assertTrue(type(p1) == type(p3))
344-
self.assertTrue(type(p2) == type(p4))
345-
self.assertTrue(type(p1) != type(p2))
346-
self.assertTrue(type(p3) != type(p4))
343+
self.assertTrue(type(p1) == type(p3)) # noqa: E721
344+
self.assertTrue(type(p2) == type(p4)) # noqa: E721
345+
self.assertTrue(type(p1) != type(p2)) # noqa: E721
346+
self.assertTrue(type(p3) != type(p4)) # noqa: E721
347347

348348

349349
class TestExpansionLimit(unittest.TestCase):

wcmatch/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,5 @@ def parse_version(ver: str) -> Version:
194194
return Version(major, minor, micro, release, pre, post, dev)
195195

196196

197-
__version_info__ = Version(8, 5, 0, "final")
197+
__version_info__ = Version(8, 5, 1, "final")
198198
__version__ = __version_info__._get_canonical()

wcmatch/glob.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ def format_path(self, path: AnyStr, is_dir: bool, dir_only: bool) -> Iterator[An
795795
def glob(self) -> Iterator[AnyStr]:
796796
"""Starts off the glob iterator."""
797797

798-
curdir = self.current
799-
800798
for pattern in self.pattern:
799+
curdir = self.current
800+
801801
# If the pattern ends with `/` we return the files ending with `/`.
802802
dir_only = pattern[-1].dir_only if pattern else False
803803
self.is_abs_pattern = pattern[0].is_drive if pattern else False

wcmatch/pathlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _translate_path(self) -> str:
113113

114114
return name + sep
115115

116-
def match(
116+
def match( # type: ignore[override, unused-ignore]
117117
self,
118118
patterns: str | Sequence[str],
119119
*,

0 commit comments

Comments
 (0)