Skip to content

Need a way to specify types for mock objects (e.g. mock.Mock()) #1188

Open
@timabbott

Description

@timabbott

Example test case code here:

if True:
    from pycurl import Curl, version_info
else:
    from mock import Mock
    Curl = Mock()
    version_info = Mock()

Posting this in mypy, since I don't think it's possible to specify a typeshed type for mock.Mock that won't throw an error; e.g. if stubs say mock.Mock is an Any, you get /home/tabbott/foo.py:7: error: Invalid assignment target

Reporting as separate from #1152 since this might be worth solving even if that is not, since most every use of mock.Mock() will have this problem.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions