mock.patch.object type annotation fails with **kwargs
Open
Nobody has claimed this yet.
stubs: false positive
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked mypy playground example with strict checking and confirm the failure around mock.patch.object and the **kwargs argument. Then inspect the unittest.mock stubs in typeshed; done means the example type-checks correctly and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100