Skip to content

Commit f5ea0ee

Browse files
committed
Use pathlib glob for file filter
1 parent fac4542 commit f5ea0ee

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

pylint/testutils/functional/test_file.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from __future__ import annotations
66

77
import configparser
8-
import os
98
import sys
109
from collections.abc import Callable
1110
from os.path import basename, exists, join
11+
from pathlib import Path
1212
from typing import TypedDict
1313

1414

@@ -101,18 +101,11 @@ def module(self) -> str:
101101

102102
@property
103103
def expected_output(self) -> str:
104-
files = list(
105-
filter(
106-
lambda s: s.startswith(f"{self.base}.") and s.endswith(".txt"),
107-
os.listdir(self._directory),
108-
)
109-
)
104+
files = [p.stem for p in Path(self._directory).glob(f"{self.base}.[0-9]*.txt")]
110105
# pylint: disable-next=bad-builtin
111106
current_version = int("".join(map(str, sys.version_info[:2])))
112107
output_options = [
113-
int(version)
114-
for s in files
115-
if s.count(".") == 2 and (version := s.rsplit(".", maxsplit=2)[1]).isalnum()
108+
int(version) for s in files if (version := s.rpartition(".")[2]).isalnum()
116109
]
117110
for opt in sorted(output_options, reverse=True):
118111
if current_version >= opt:

0 commit comments

Comments
 (0)