Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_slack_importer: Fix strict_optional errors.

Anders Kaseorg2a0e5616f14e
diff --git a/mypy.ini b/mypy.ini
index f71c610511d..e88391f7a8b 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -40,8 +40,6 @@ strict_optional = True
# 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"
strict_optional = False
[mypy-zerver/tests/test_outgoing_webhook_system] #33: error: Argument 1 to "MockServiceHandler" has incompatible type "None"; expected "str"
diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.py
index 3e0ec991220..52c86560782 100644
--- a/zerver/tests/test_slack_importer.py
+++ b/zerver/tests/test_slack_importer.py
@@ -1,7 +1,7 @@
import logging
import os
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.mock import ANY, call
@@ -50,11 +50,11 @@ def remove_folder(path: str) -> None:
shutil.rmtree(path)
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.status_code = status_code
- def json(self) -> Dict[str, Any]:
+ def json(self) -> Optional[Dict[str, Any]]:
return self.json_data
# This method will be used by the mock to replace requests.get