Skip to content

Commit 4d633a2

Browse files
authored
cacheprovider: fix typing with Path(py.path.local) (#6774)
Fixes: > Argument 1 to "Path" has incompatible type "Union[local, Any]"; > expected "Union[str, _PathLike[str]]" [arg-type] Ref: pytest-dev/py#232 (review)
1 parent 8a1633c commit 4d633a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/_pytest/cacheprovider.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ def pytest_make_collect_report(self, collector) -> Generator:
181181
# Sort any lf-paths to the beginning.
182182
lf_paths = self.lfplugin._last_failed_paths
183183
res.result = sorted(
184-
res.result, key=lambda x: 0 if Path(x.fspath) in lf_paths else 1,
184+
res.result, key=lambda x: 0 if Path(str(x.fspath)) in lf_paths else 1,
185185
)
186186
out.force_result(res)
187187
return
188188

189189
elif isinstance(collector, Module):
190-
if Path(collector.fspath) in self.lfplugin._last_failed_paths:
190+
if Path(str(collector.fspath)) in self.lfplugin._last_failed_paths:
191191
out = yield
192192
res = out.get_result()
193193

@@ -214,7 +214,7 @@ def __init__(self, lfplugin: "LFPlugin"):
214214
@pytest.hookimpl
215215
def pytest_make_collect_report(self, collector) -> Optional[CollectReport]:
216216
if isinstance(collector, Module):
217-
if Path(collector.fspath) not in self.lfplugin._last_failed_paths:
217+
if Path(str(collector.fspath)) not in self.lfplugin._last_failed_paths:
218218
self.lfplugin._skipped_files += 1
219219

220220
return CollectReport(
@@ -246,7 +246,7 @@ def __init__(self, config: Config) -> None:
246246

247247
def get_last_failed_paths(self) -> Set[Path]:
248248
"""Returns a set with all Paths()s of the previously failed nodeids."""
249-
rootpath = Path(self.config.rootdir)
249+
rootpath = Path(str(self.config.rootdir))
250250
result = {rootpath / nodeid.split("::")[0] for nodeid in self.lastfailed}
251251
return {x for x in result if x.exists()}
252252

0 commit comments

Comments
 (0)