Skip to content

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

@bluenote10

Description

@bluenote10

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions