Skip to content

Commit a550db4

Browse files
drop internal py.path.local objects from hook calls
1 parent 30f1b81 commit a550db4

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

src/_pytest/main.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,8 @@ def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
563563
if direntry.name == "__pycache__":
564564
return False
565565
fspath = Path(direntry.path)
566-
path = legacy_path(fspath)
567566
ihook = self.gethookproxy(fspath.parent)
568-
if ihook.pytest_ignore_collect(fspath=fspath, path=path, config=self.config):
567+
if ihook.pytest_ignore_collect(fspath=fspath, config=self.config):
569568
return False
570569
norecursepatterns = self.config.getini("norecursedirs")
571570
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
@@ -575,17 +574,14 @@ def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
575574
def _collectfile(
576575
self, fspath: Path, handle_dupes: bool = True
577576
) -> Sequence[nodes.Collector]:
578-
path = legacy_path(fspath)
579577
assert (
580578
fspath.is_file()
581579
), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
582580
fspath, fspath.is_dir(), fspath.exists(), fspath.is_symlink()
583581
)
584582
ihook = self.gethookproxy(fspath)
585583
if not self.isinitpath(fspath):
586-
if ihook.pytest_ignore_collect(
587-
fspath=fspath, path=path, config=self.config
588-
):
584+
if ihook.pytest_ignore_collect(fspath=fspath, config=self.config):
589585
return ()
590586

591587
if handle_dupes:
@@ -597,7 +593,7 @@ def _collectfile(
597593
else:
598594
duplicate_paths.add(fspath)
599595

600-
return ihook.pytest_collect_file(fspath=fspath, path=path, parent=self) # type: ignore[no-any-return]
596+
return ihook.pytest_collect_file(fspath=fspath, parent=self) # type: ignore[no-any-return]
601597

602598
@overload
603599
def perform_collect(

src/_pytest/python.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,15 @@ def pytest_pyfunc_call(pyfuncitem: "Function") -> Optional[object]:
188188
return True
189189

190190

191-
def pytest_collect_file(
192-
fspath: Path, path: LEGACY_PATH, parent: nodes.Collector
193-
) -> Optional["Module"]:
191+
def pytest_collect_file(fspath: Path, parent: nodes.Collector) -> Optional["Module"]:
194192
if fspath.suffix == ".py":
195193
if not parent.session.isinitpath(fspath):
196194
if not path_matches_patterns(
197195
fspath, parent.config.getini("python_files") + ["__init__.py"]
198196
):
199197
return None
200198
ihook = parent.session.gethookproxy(fspath)
201-
module: Module = ihook.pytest_pycollect_makemodule(
202-
fspath=fspath, path=path, parent=parent
203-
)
199+
module: Module = ihook.pytest_pycollect_makemodule(fspath=fspath, parent=parent)
204200
return module
205201
return None
206202

@@ -675,9 +671,8 @@ def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
675671
if direntry.name == "__pycache__":
676672
return False
677673
fspath = Path(direntry.path)
678-
path = legacy_path(fspath)
679674
ihook = self.session.gethookproxy(fspath.parent)
680-
if ihook.pytest_ignore_collect(fspath=fspath, path=path, config=self.config):
675+
if ihook.pytest_ignore_collect(fspath=fspath, config=self.config):
681676
return False
682677
norecursepatterns = self.config.getini("norecursedirs")
683678
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
@@ -687,17 +682,14 @@ def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
687682
def _collectfile(
688683
self, fspath: Path, handle_dupes: bool = True
689684
) -> Sequence[nodes.Collector]:
690-
path = legacy_path(fspath)
691685
assert (
692686
fspath.is_file()
693687
), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
694688
fspath, fspath.is_dir(), fspath.exists(), fspath.is_symlink()
695689
)
696690
ihook = self.session.gethookproxy(fspath)
697691
if not self.session.isinitpath(fspath):
698-
if ihook.pytest_ignore_collect(
699-
fspath=fspath, path=path, config=self.config
700-
):
692+
if ihook.pytest_ignore_collect(fspath=fspath, config=self.config):
701693
return ()
702694

703695
if handle_dupes:
@@ -709,7 +701,7 @@ def _collectfile(
709701
else:
710702
duplicate_paths.add(fspath)
711703

712-
return ihook.pytest_collect_file(fspath=fspath, path=path, parent=self) # type: ignore[no-any-return]
704+
return ihook.pytest_collect_file(fspath=fspath, parent=self) # type: ignore[no-any-return]
713705

714706
def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
715707
this_path = self.path.parent

src/_pytest/terminal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ def pytest_sessionstart(self, session: "Session") -> None:
716716
msg += " -- " + str(sys.executable)
717717
self.write_line(msg)
718718
lines = self.config.hook.pytest_report_header(
719-
config=self.config, startpath=self.startpath, startdir=self.startdir
719+
config=self.config, startpath=self.startpath
720720
)
721721
self._write_report_lines_from_hooks(lines)
722722

@@ -753,7 +753,6 @@ def pytest_collection_finish(self, session: "Session") -> None:
753753
lines = self.config.hook.pytest_report_collectionfinish(
754754
config=self.config,
755755
startpath=self.startpath,
756-
startdir=self.startdir,
757756
items=session.items,
758757
)
759758
self._write_report_lines_from_hooks(lines)

0 commit comments

Comments
 (0)