From 43654b9cf2ca2c7e7877d08134218ee2fe9ae6ff Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 26 Oct 2023 13:43:42 -0700 Subject: [PATCH] mypy: Enable ignore-without-code error. Signed-off-by: Anders Kaseorg --- pyproject.toml | 1 + zulip/zulip/__init__.py | 6 +++--- zulip_bots/zulip_bots/request_test_lib.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 86688ecc..f83e6963 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ enable_error_code = [ "redundant-expr", "truthy-bool", "truthy-iterable", + "ignore-without-code", "unused-awaitable", ] diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index d32a8040..72508d12 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -154,7 +154,7 @@ def add_default_arguments( self.print_help(sys.stderr) self.exit(2, f"{self.prog}: error: {message}\n") - parser.error = types.MethodType(custom_error_handling, parser) # type: ignore # patching function + parser.error = types.MethodType(custom_error_handling, parser) # type: ignore[method-assign] # patching function if allow_provisioning: parser.add_argument( @@ -1802,7 +1802,7 @@ if LEGACY_CLIENT_INTERFACE_FROM_SERVER_DOCS_VERSION == "3": # This block is support for testing Zulip 3.x, which documents old # interfaces for the following functions: class LegacyInterfaceClient(Client): - def update_user_group_members(self, group_data: Dict[str, Any]) -> Dict[str, Any]: # type: ignore # Intentional override; see comments above. + def update_user_group_members(self, group_data: Dict[str, Any]) -> Dict[str, Any]: # type: ignore[override] # Intentional override; see comments above. modern_group_data = group_data.copy() group_id = group_data["group_id"] del modern_group_data["group_id"] @@ -1821,4 +1821,4 @@ if LEGACY_CLIENT_INTERFACE_FROM_SERVER_DOCS_VERSION == "3": method="GET", ) - Client = LegacyInterfaceClient # type: ignore # Intentional override; see comments above. + Client = LegacyInterfaceClient # type: ignore[misc] # Intentional override; see comments above. diff --git a/zulip_bots/zulip_bots/request_test_lib.py b/zulip_bots/zulip_bots/request_test_lib.py index 9bc2ae24..72d7163d 100644 --- a/zulip_bots/zulip_bots/request_test_lib.py +++ b/zulip_bots/zulip_bots/request_test_lib.py @@ -30,7 +30,7 @@ def mock_http_conversation(http_data: Dict[str, Any]) -> Any: mock_result.headers.update(http_headers) mock_result.encoding = get_encoding_from_headers(mock_result.headers) 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[attr-defined] # This modifies a "hidden" attribute. else: mock_result._content = json.dumps(http_response).encode() return mock_result