mypy: Remove unused type: ignore comments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
5b5fda2354
commit
30f241a126
2
mypy.ini
2
mypy.ini
|
@ -9,3 +9,5 @@ scripts_are_modules = True
|
||||||
show_traceback = True
|
show_traceback = True
|
||||||
|
|
||||||
warn_no_return = True
|
warn_no_return = True
|
||||||
|
warn_redundant_casts = True
|
||||||
|
warn_unused_ignores = True
|
||||||
|
|
|
@ -58,7 +58,7 @@ def make_api_call(path: str) -> Optional[List[Dict[str, Any]]]:
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Accept": "application/json"})
|
"Accept": "application/json"})
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
return json.loads(response.text) # type: ignore # dynamic import
|
return json.loads(response.text)
|
||||||
|
|
||||||
if response.status_code >= 500:
|
if response.status_code >= 500:
|
||||||
logging.error(str(response.status_code))
|
logging.error(str(response.status_code))
|
||||||
|
|
|
@ -113,7 +113,7 @@ if __name__ == "__main__":
|
||||||
zulip_client = zulip.init_from_options(args)
|
zulip_client = zulip.init_from_options(args)
|
||||||
try:
|
try:
|
||||||
log_files = json.loads(open(args.control_path).read())
|
log_files = json.loads(open(args.control_path).read())
|
||||||
except (json.JSONDecodeError, OSError): # type: ignore # error: Cannot determine type of 'IOError'
|
except (json.JSONDecodeError, OSError):
|
||||||
print("Could not load control data from %s" % (args.control_path,))
|
print("Could not load control data from %s" % (args.control_path,))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TestDefaultArguments(TestCase):
|
||||||
|
|
||||||
def test_invalid_arguments(self) -> None:
|
def test_invalid_arguments(self) -> None:
|
||||||
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
|
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
|
||||||
with self.assertRaises(SystemExit) as cm: # type: ignore # error: "assertRaises" doesn't match argument types
|
with self.assertRaises(SystemExit) as cm:
|
||||||
with patch('sys.stderr', new=io.StringIO()) as mock_stderr:
|
with patch('sys.stderr', new=io.StringIO()) as mock_stderr:
|
||||||
parser.parse_args(['invalid argument'])
|
parser.parse_args(['invalid argument'])
|
||||||
self.assertEqual(cm.exception.code, 2)
|
self.assertEqual(cm.exception.code, 2)
|
||||||
|
|
|
@ -437,7 +437,7 @@ class Client:
|
||||||
# Actually construct the session
|
# Actually construct the session
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
session.auth = requests.auth.HTTPBasicAuth(self.email, self.api_key)
|
session.auth = requests.auth.HTTPBasicAuth(self.email, self.api_key)
|
||||||
session.verify = self.tls_verification # type: ignore # https://github.com/python/typeshed/pull/1504
|
session.verify = self.tls_verification
|
||||||
session.cert = client_cert
|
session.cert = client_cert
|
||||||
session.headers.update({"User-agent": self.get_user_agent()})
|
session.headers.update({"User-agent": self.get_user_agent()})
|
||||||
self.session = session
|
self.session = session
|
||||||
|
|
|
@ -25,7 +25,7 @@ def mock_http_conversation(http_data: Dict[str, Any]) -> Any:
|
||||||
if is_raw_response:
|
if is_raw_response:
|
||||||
mock_result._content = http_response.encode() # type: ignore # This modifies a "hidden" attribute.
|
mock_result._content = http_response.encode() # type: ignore # This modifies a "hidden" attribute.
|
||||||
else:
|
else:
|
||||||
mock_result._content = json.dumps(http_response).encode() # type: ignore # See above.
|
mock_result._content = json.dumps(http_response).encode()
|
||||||
mock_result.status_code = http_headers.get('status', 200)
|
mock_result.status_code = http_headers.get('status', 200)
|
||||||
return mock_result
|
return mock_result
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ class BotServerTests(BotServerTestCase):
|
||||||
# This works, but mypy still complains:
|
# This works, but mypy still complains:
|
||||||
# error: No overload variant of "assertRaisesRegexp" of "TestCase" matches argument types
|
# error: No overload variant of "assertRaisesRegexp" of "TestCase" matches argument types
|
||||||
# [def (*args: builtins.object, **kwargs: builtins.object) -> builtins.SystemExit, builtins.str]
|
# [def (*args: builtins.object, **kwargs: builtins.object) -> builtins.SystemExit, builtins.str]
|
||||||
with self.assertRaisesRegexp(SystemExit, # type: ignore
|
with self.assertRaisesRegexp(SystemExit,
|
||||||
'Error: Bot "nonexistent-bot" doesn\'t exist. Please make '
|
'Error: Bot "nonexistent-bot" doesn\'t exist. Please make '
|
||||||
'sure you have set up the botserverrc file correctly.'):
|
'sure you have set up the botserverrc file correctly.'):
|
||||||
self.assert_bot_server_response(
|
self.assert_bot_server_response(
|
||||||
|
@ -228,13 +228,13 @@ class BotServerTests(BotServerTestCase):
|
||||||
assert isinstance(module, ModuleType)
|
assert isinstance(module, ModuleType)
|
||||||
|
|
||||||
# load invalid module name
|
# load invalid module name
|
||||||
with self.assertRaisesRegexp(SystemExit, # type: ignore
|
with self.assertRaisesRegexp(SystemExit,
|
||||||
'Error: Bot "botserver-test-case-random-bot" doesn\'t exist. '
|
'Error: Bot "botserver-test-case-random-bot" doesn\'t exist. '
|
||||||
'Please make sure you have set up the botserverrc file correctly.'):
|
'Please make sure you have set up the botserverrc file correctly.'):
|
||||||
module = server.load_lib_modules(['botserver-test-case-random-bot'])['botserver-test-case-random-bot']
|
module = server.load_lib_modules(['botserver-test-case-random-bot'])['botserver-test-case-random-bot']
|
||||||
|
|
||||||
# load invalid file path
|
# load invalid file path
|
||||||
with self.assertRaisesRegexp(SystemExit, # type: ignore
|
with self.assertRaisesRegexp(SystemExit,
|
||||||
'Error: Bot "{}/zulip_bots/zulip_bots/bots/helloworld.py" doesn\'t exist. '
|
'Error: Bot "{}/zulip_bots/zulip_bots/bots/helloworld.py" doesn\'t exist. '
|
||||||
'Please make sure you have set up the botserverrc file correctly.'.format(root_dir)):
|
'Please make sure you have set up the botserverrc file correctly.'.format(root_dir)):
|
||||||
path = Path(root_dir, 'zulip_bots/zulip_bots/bots/{bot}.py'.format(bot='helloworld')).as_posix()
|
path = Path(root_dir, 'zulip_bots/zulip_bots/bots/{bot}.py'.format(bot='helloworld')).as_posix()
|
||||||
|
|
Loading…
Reference in a new issue