test_slack_importer: Fix strict_optional errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-07-04 15:37:32 -07:00
committed by Tim Abbott
parent 489d73f63a
commit 2a0e5616f1
2 changed files with 3 additions and 5 deletions

View File

@@ -40,8 +40,6 @@ strict_optional = True
# Tests (may be many issues in file; comment is just one error noted) # Tests (may be many issues in file; comment is just one error noted)
[mypy-zerver/tests/test_slack_importer] #70: error: Argument 1 to "MockResponse" has incompatible type "None"; expected "Dict[str, Any]"
strict_optional = False
[mypy-zerver/tests/test_service_bot_system] #312: error: Argument 1 to "set_bot_config" has incompatible type "Optional[UserProfile]"; expected "UserProfile" [mypy-zerver/tests/test_service_bot_system] #312: error: Argument 1 to "set_bot_config" has incompatible type "Optional[UserProfile]"; expected "UserProfile"
strict_optional = False strict_optional = False
[mypy-zerver/tests/test_outgoing_webhook_system] #33: error: Argument 1 to "MockServiceHandler" has incompatible type "None"; expected "str" [mypy-zerver/tests/test_outgoing_webhook_system] #33: error: Argument 1 to "MockServiceHandler" has incompatible type "None"; expected "str"

View File

@@ -1,7 +1,7 @@
import logging import logging
import os import os
import shutil import shutil
from typing import Any, Dict, Iterator, List, Set, Tuple from typing import Any, Dict, Iterator, List, Optional, Set, Tuple
from unittest import mock from unittest import mock
from unittest.mock import ANY, call from unittest.mock import ANY, call
@@ -50,11 +50,11 @@ def remove_folder(path: str) -> None:
shutil.rmtree(path) shutil.rmtree(path)
class MockResponse: class MockResponse:
def __init__(self, json_data: Dict[str, Any], status_code: int) -> None: def __init__(self, json_data: Optional[Dict[str, Any]], status_code: int) -> None:
self.json_data = json_data self.json_data = json_data
self.status_code = status_code self.status_code = status_code
def json(self) -> Dict[str, Any]: def json(self) -> Optional[Dict[str, Any]]:
return self.json_data return self.json_data
# This method will be used by the mock to replace requests.get # This method will be used by the mock to replace requests.get