Skip to content

Commit b55db66

Browse files
Address fnmatch review comments
1 parent e968f2f commit b55db66

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎Lib/fnmatch.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ def _compile_pattern(pat):
5050

5151
def filter(names, pat):
5252
"""Construct a list from those elements of the iterable NAMES that match PAT."""
53-
result = []
5453
pat = os.path.normcase(pat)
5554
match = _compile_pattern(pat)
56-
for name in names:
57-
if match(os.path.normcase(name)):
58-
result.append(name)
59-
return result
55+
return [
56+
name for name in names
57+
if match(os.path.normcase(name))
58+
]
6059

6160

6261
def filterfalse(names, pat):

‎Lib/test/test_fnmatch.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ def test_mix_bytes_str(self):
332332
self.assertRaises(TypeError, filter, ['test'], b'*')
333333
self.assertRaises(TypeError, filter, [b'test'], '*')
334334

335-
336335
def test_mix_bytes_str_pathlike(self):
337336
path = pathlib.Path("test")
338337
self.assertRaises(TypeError, filter, [path], b'*')
@@ -370,7 +369,6 @@ def test_mix_bytes_str(self):
370369
self.assertRaises(TypeError, filterfalse, ['test'], b'*')
371370
self.assertRaises(TypeError, filterfalse, [b'test'], '*')
372371

373-
374372
def test_mix_bytes_str_pathlike(self):
375373
path = pathlib.Path("test")
376374
self.assertRaises(TypeError, filterfalse, [path], b'*')

0 commit comments

Comments
 (0)