From 42fddd3b0c8b8ae951c096b0a9082d933351a4b1 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sat, 13 May 2023 21:16:16 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Ran Benita --- changelog/10999.bugfix.rst | 2 +- src/_pytest/monkeypatch.py | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/changelog/10999.bugfix.rst b/changelog/10999.bugfix.rst index 1eeae02b1..08c68da01 100644 --- a/changelog/10999.bugfix.rst +++ b/changelog/10999.bugfix.rst @@ -1 +1 @@ -Fixed bug where monkeypatch setitem/delitem type annotations didn't support typing.TypedDict. +The `monkeypatch` `setitem`/`delitem` type annotations now allow `TypedDict` arguments. diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index 6d63da443..c4a72e49d 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -295,12 +295,7 @@ class MonkeyPatch: self._setitem.append((dic, name, dic.get(name, notset))) dic[name] = value - def delitem( - self, - dic: Mapping[K, V], - name: K, - raising: bool = True, - ) -> None: + def delitem(self, dic: Mapping[K, V], name: K, raising: bool = True) -> None: """Delete ``name`` from dict. Raises ``KeyError`` if it doesn't exist, unless ``raising`` is set to @@ -341,7 +336,7 @@ class MonkeyPatch: Raises ``KeyError`` if it does not exist, unless ``raising`` is set to False. """ - environ: Mapping[str, str] = os.environ + environ: MutableMapping[str, str] = os.environ self.delitem(environ, name, raising=raising) def syspath_prepend(self, path) -> None: