Skip to content

mock.patch.multiple(..., **patches) type checks against non-**kwargs arguments #8525

@asottile

Description

@asottile

example:

import os
from unittest import mock


patches = {'listdir': lambda x: ['t']}
with mock.patch.multiple(os, **patches):
    pass

output:

$ mypy --version
mypy 0.770
$ mypy t.py
t.py:6: error: Argument 2 to "multiple" of "_patcher" has incompatible type "**Dict[str, Callable[[Any], List[str]]]"; expected "bool"
Found 1 error in 1 file (checked 1 source file)

expected: no errors -- the stub for multiple takes **kwargs: Any: https://github.com/python/typeshed/blob/508fd844992f5ba8398fec5defa5bb7a44c71269/stdlib/3/unittest/mock.pyi#L91

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