Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock.patch.object type annotation fails with **kwargs #7542

Open
graingert opened this issue Mar 24, 2022 · 2 comments · Fixed by #7543
Open

mock.patch.object type annotation fails with **kwargs #7542

graingert opened this issue Mar 24, 2022 · 2 comments · Fixed by #7543
Labels
stubs: false positive Type checkers report false errors

Comments

@graingert
Copy link
Contributor

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
@srittau
Copy link
Collaborator

srittau commented Mar 24, 2022

mock.patch.object() should probably be marked as a staticmethod in the stubs. (The same for dict(), multiple(), and stopall().)

@srittau srittau added the stubs: false positive Type checkers report false errors label Mar 24, 2022
srittau added a commit to srittau/typeshed that referenced this issue Mar 24, 2022
@AlexWaygood AlexWaygood added the status: deferred Issue or PR deferred until some precondition is fixed label Jun 12, 2022
@AlexWaygood AlexWaygood removed the status: deferred Issue or PR deferred until some precondition is fixed label Nov 1, 2022
@AlexWaygood
Copy link
Member

Reopening as per #7543 (review) -- the original snippet still causes mypy to emit a false-positive error, even using mypy master and typeshed master.

@AlexWaygood AlexWaygood reopened this Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
3 participants