Skip to content

Commit

Permalink
cacheprovider: fix typing with Path(py.path.local) (#6774)
Browse files Browse the repository at this point in the history
Fixes:

> Argument 1 to "Path" has incompatible type "Union[local, Any]";
> expected "Union[str, _PathLike[str]]"  [arg-type]

Ref: pytest-dev/py#232 (review)
  • Loading branch information
blueyed authored Feb 20, 2020
1 parent 8a1633c commit 4d633a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ def pytest_make_collect_report(self, collector) -> Generator:
# Sort any lf-paths to the beginning.
lf_paths = self.lfplugin._last_failed_paths
res.result = sorted(
res.result, key=lambda x: 0 if Path(x.fspath) in lf_paths else 1,
res.result, key=lambda x: 0 if Path(str(x.fspath)) in lf_paths else 1,
)
out.force_result(res)
return

elif isinstance(collector, Module):
if Path(collector.fspath) in self.lfplugin._last_failed_paths:
if Path(str(collector.fspath)) in self.lfplugin._last_failed_paths:
out = yield
res = out.get_result()

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

return CollectReport(
Expand Down Expand Up @@ -246,7 +246,7 @@ def __init__(self, config: Config) -> None:

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

Expand Down

0 comments on commit 4d633a2

Please sign in to comment.