{"action":"created","issue":{"url":"https://api.github.com/repos/python/mypy/issues/1188","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/1188/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/1188/comments","events_url":"https://api.github.com/repos/python/mypy/issues/1188/events","html_url":"https://github.com/python/mypy/issues/1188","id":129616102,"node_id":"MDU6SXNzdWUxMjk2MTYxMDI=","number":1188,"title":"Need a way to specify types for mock objects (e.g. mock.Mock())","user":{"login":"timabbott","id":2746074,"node_id":"MDQ6VXNlcjI3NDYwNzQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2746074?v=4","gravatar_id":"","url":"https://api.github.com/users/timabbott","html_url":"https://github.com/timabbott","followers_url":"https://api.github.com/users/timabbott/followers","following_url":"https://api.github.com/users/timabbott/following{/other_user}","gists_url":"https://api.github.com/users/timabbott/gists{/gist_id}","starred_url":"https://api.github.com/users/timabbott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timabbott/subscriptions","organizations_url":"https://api.github.com/users/timabbott/orgs","repos_url":"https://api.github.com/users/timabbott/repos","events_url":"https://api.github.com/users/timabbott/events{/privacy}","received_events_url":"https://api.github.com/users/timabbott/received_events","type":"User","site_admin":false},"labels":[{"id":936639327,"node_id":"MDU6TGFiZWw5MzY2MzkzMjc=","url":"https://api.github.com/repos/python/mypy/labels/false-positive","name":"false-positive","color":"fc2092","default":false},{"id":21488358,"node_id":"MDU6TGFiZWwyMTQ4ODM1OA==","url":"https://api.github.com/repos/python/mypy/labels/feature","name":"feature","color":"84b6eb","default":false},{"id":513232552,"node_id":"MDU6TGFiZWw1MTMyMzI1NTI=","url":"https://api.github.com/repos/python/mypy/labels/priority-1-normal","name":"priority-1-normal","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-01-28T23:24:41Z","updated_at":"2018-06-22T16:00:47Z","closed_at":null,"author_association":"NONE","body":"Example test case code here:\n\n```\nif True:\n    from pycurl import Curl, version_info\nelse:\n    from mock import Mock\n    Curl = Mock()\n    version_info = Mock()\n```\n\nPosting 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`\n\nReporting 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.\n"},"comment":{"url":"https://api.github.com/repos/python/mypy/issues/comments/399492330","html_url":"https://github.com/python/mypy/issues/1188#issuecomment-399492330","issue_url":"https://api.github.com/repos/python/mypy/issues/1188","id":399492330,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTQ5MjMzMA==","user":{"login":"kkreezy","id":8921800,"node_id":"MDQ6VXNlcjg5MjE4MDA=","avatar_url":"https://avatars3.githubusercontent.com/u/8921800?v=4","gravatar_id":"","url":"https://api.github.com/users/kkreezy","html_url":"https://github.com/kkreezy","followers_url":"https://api.github.com/users/kkreezy/followers","following_url":"https://api.github.com/users/kkreezy/following{/other_user}","gists_url":"https://api.github.com/users/kkreezy/gists{/gist_id}","starred_url":"https://api.github.com/users/kkreezy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kkreezy/subscriptions","organizations_url":"https://api.github.com/users/kkreezy/orgs","repos_url":"https://api.github.com/users/kkreezy/repos","events_url":"https://api.github.com/users/kkreezy/events{/privacy}","received_events_url":"https://api.github.com/users/kkreezy/received_events","type":"User","site_admin":false},"created_at":"2018-06-22T16:00:47Z","updated_at":"2018-06-22T16:00:47Z","author_association":"NONE","body":"I'm writing unit tests and this is a real nuisance for PEP8 compliance.\r\n\r\nexample code:\r\n\r\n\r\n\r\n`\r\nclass FactoryHandler:\r\n\"\"\"\r\n:param worker:\r\n:type worker:\r\n\"\"\"\r\n\r\nclass TestFactoryHandler\r\n    def test_something(self):\r\n         worker = MagicMock()\r\n         factory = FactoryHandler(worker)\r\n`\r\n\r\nPEP8 Type check will throw a warning saying it expected a type worker but got type magic mock instead.\r\nAs far as I know, all I can do is # no inspection the line. "}}
{"actor":{"display_login":"kkreezy"}}