Skip to content

Spy type is missing extra attributes #547

@glukki

Description

@glukki

According to the documentation and code Spy provides extra attributes: https://pytest-mock.readthedocs.io/en/latest/usage.html#spy

spy_obj = self.patch.object(obj, name, side_effect=wrapped, autospec=autospec)
spy_obj.spy_return = None
spy_obj.spy_return_iter = None
spy_obj.spy_return_list = []
spy_obj.spy_exception = None
return spy_obj

But they're not listed in the Spy type.

Spy definition:

def spy(
self, obj: object, name: str, duplicate_iterators: bool = False
) -> MockType:

Spy type definition:

MockType = Union[
unittest.mock.MagicMock,
unittest.mock.AsyncMock,
unittest.mock.NonCallableMagicMock,
]

This breaks autocomplete 😢

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions