diff --git a/AUTHORS b/AUTHORS index daa6a471eb9..ae04e587921 100644 --- a/AUTHORS +++ b/AUTHORS @@ -8,6 +8,7 @@ Abdeali JK Abdelrahman Elbehery Abhijeet Kasurde ace2016 +Adam Dangoor Adam Johnson Adam Stewart Adam Uhlir diff --git a/changelog/14988.improvement.rst b/changelog/14988.improvement.rst new file mode 100644 index 00000000000..724425456e0 --- /dev/null +++ b/changelog/14988.improvement.rst @@ -0,0 +1 @@ +:meth:`MonkeyPatch.syspath_prepend ` now annotates its ``path`` parameter as ``str | os.PathLike[str]``, so strict type checkers no longer report calls to it as having an unknown type. diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index 453c6728ee2..d4f5695be9e 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -360,7 +360,7 @@ def delenv(self, name: str, raising: bool = True) -> None: environ: MutableMapping[str, str] = os.environ self.delitem(environ, name, raising=raising) - def syspath_prepend(self, path) -> None: + def syspath_prepend(self, path: str | os.PathLike[str]) -> None: """Prepend ``path`` to ``sys.path`` list of import locations.""" if self._savesyspath is None: self._savesyspath = sys.path[:]