Skip to content

Using mock.patch as a decorator doesn't properly forward the underlying function signature (even with a new= argument) #10324

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

Closed
bluenote10 opened this issue Jun 16, 2023 · 0 comments · Fixed by #10325
Labels
stubs: false negative Type checkers do not report an error, but should

Comments

@bluenote10
Copy link

The following seems to type check fine (both mypy and pyright) even though it should not (I would hope):

from unittest.mock import Mock, patch

@patch("sys.exit", new=Mock())
def f(i: int) -> None:
    ...

f("a")

Tried with types-mock==5.0.0.6.

hauntsaninja added a commit to hauntsaninja/typeshed that referenced this issue Jun 16, 2023
@srittau srittau added the stubs: false negative Type checkers do not report an error, but should label Jun 16, 2023
srittau pushed a commit that referenced this issue Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false negative Type checkers do not report an error, but should
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants