typeshed
typeshed copied to clipboard
mock.patch.object type annotation fails with **kwargs
https://mypy-play.net/?mypy=latest&python=3.10&gist=6f7d6d1036646b8e8a41ed3a5dab3b98&flags=strict
from unittest import mock
import subprocess
def foo() -> None:
with mock.patch.object(
subprocess,
"Popen",
**{"return_value.communicate.side_effect": KeyboardInterrupt}
):
pass
mock.patch.object() should probably be marked as a staticmethod in the stubs. (The same for dict(), multiple(), and stopall().)
Reopening as per https://github.com/python/typeshed/pull/7543#pullrequestreview-1123222530 -- the original snippet still causes mypy to emit a false-positive error, even using mypy master and typeshed master.