Skip to content

Commit b25a3ad

Browse files
authored
Merge pull request #11192 from bluetech/py38-extra
A few more Python>=3.8 simplifications
2 parents b20e7f6 + f1c9570 commit b25a3ad

File tree

4 files changed

+6
-29
lines changed

4 files changed

+6
-29
lines changed

doc/en/how-to/failures.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ Warning about unraisable exceptions and unhandled thread exceptions
135135

136136
.. versionadded:: 6.2
137137

138-
.. note::
139-
140-
These features only work on Python>=3.8.
141-
142138
Unhandled exceptions are exceptions that are raised in a situation in which
143139
they cannot propagate to a caller. The most common case is an exception raised
144140
in a :meth:`__del__ <object.__del__>` implementation.

src/_pytest/_code/code.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,11 @@ def __getitem__(
393393

394394
def filter(
395395
self,
396-
# TODO(py38): change to positional only.
397-
_excinfo_or_fn: Union[
396+
excinfo_or_fn: Union[
398397
"ExceptionInfo[BaseException]",
399398
Callable[[TracebackEntry], bool],
400399
],
400+
/,
401401
) -> "Traceback":
402402
"""Return a Traceback instance with certain items removed.
403403
@@ -408,10 +408,10 @@ def filter(
408408
``TracebackEntry`` instance, and should return True when the item should
409409
be added to the ``Traceback``, False when not.
410410
"""
411-
if isinstance(_excinfo_or_fn, ExceptionInfo):
412-
fn = lambda x: not x.ishidden(_excinfo_or_fn) # noqa: E731
411+
if isinstance(excinfo_or_fn, ExceptionInfo):
412+
fn = lambda x: not x.ishidden(excinfo_or_fn) # noqa: E731
413413
else:
414-
fn = _excinfo_or_fn
414+
fn = excinfo_or_fn
415415
return Traceback(filter(fn, self))
416416

417417
def recursionindex(self) -> Optional[int]:

src/_pytest/pathlib.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -769,21 +769,3 @@ def bestrelpath(directory: Path, dest: Path) -> str:
769769
# Forward from base to dest.
770770
*reldest.parts,
771771
)
772-
773-
774-
# Originates from py. path.local.copy(), with siginficant trims and adjustments.
775-
# TODO(py38): Replace with shutil.copytree(..., symlinks=True, dirs_exist_ok=True)
776-
def copytree(source: Path, target: Path) -> None:
777-
"""Recursively copy a source directory to target."""
778-
assert source.is_dir()
779-
for entry in visit(source, recurse=lambda entry: not entry.is_symlink()):
780-
x = Path(entry)
781-
relpath = x.relative_to(source)
782-
newx = target / relpath
783-
newx.parent.mkdir(exist_ok=True)
784-
if x.is_symlink():
785-
newx.symlink_to(os.readlink(x))
786-
elif x.is_file():
787-
shutil.copyfile(x, newx)
788-
elif x.is_dir():
789-
newx.mkdir(exist_ok=True)

src/_pytest/pytester.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
from _pytest.outcomes import importorskip
6464
from _pytest.outcomes import skip
6565
from _pytest.pathlib import bestrelpath
66-
from _pytest.pathlib import copytree
6766
from _pytest.pathlib import make_numbered_dir
6867
from _pytest.reports import CollectReport
6968
from _pytest.reports import TestReport
@@ -971,7 +970,7 @@ def copy_example(self, name: Optional[str] = None) -> Path:
971970
example_path = example_dir.joinpath(name)
972971

973972
if example_path.is_dir() and not example_path.joinpath("__init__.py").is_file():
974-
copytree(example_path, self.path)
973+
shutil.copytree(example_path, self.path, symlinks=True, dirs_exist_ok=True)
975974
return self.path
976975
elif example_path.is_file():
977976
result = self.path.joinpath(example_path.name)

0 commit comments

Comments
 (0)