Skip to content

incorrect types for functions decorated with @mock.patch #10457

@svalentin

Description

@svalentin

Looks like we have a typeshed bug:

from unittest.mock import patch

def addition(a: int, b:int) -> int:
    return a+b

@patch('test.addition')
def patch_test(mock):
    print(mock)

if __name__ == "__main__":
    patch_test()

In this simple example mypy says:

test.py:12: error: Missing positional argument "mock" in call to "patch_test"  [call-arg]

Undoing 9e86c60 fixes it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions