From 2a0e5616f14ec9cab2d1e3ae77148490ddc2762e Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 4 Jul 2020 15:37:32 -0700 Subject: [PATCH] test_slack_importer: Fix strict_optional errors. Signed-off-by: Anders Kaseorg --- mypy.ini | 2 -- zerver/tests/test_slack_importer.py | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mypy.ini b/mypy.ini index f71c610511..e88391f7a8 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 3e0ec99122..52c8656078 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