diff --git a/lib/dl_api_lib/dl_api_lib/app/control_api/resources/connections.py b/lib/dl_api_lib/dl_api_lib/app/control_api/resources/connections.py index e48c79fef..201e41d32 100644 --- a/lib/dl_api_lib/dl_api_lib/app/control_api/resources/connections.py +++ b/lib/dl_api_lib/dl_api_lib/app/control_api/resources/connections.py @@ -67,10 +67,11 @@ def _handle_conn_test_exc(exception: Exception) -> NoReturn: @ns.route("/test_connection_params") class ConnectionParamsTester(BIResource): @schematic_request(ns=ns) - def post(self): # type: ignore # TODO: fix + def post(self) -> None: service_registry = self.get_service_registry() schema = GenericConnectionSchema(context=self.get_schema_ctx(schema_operations_mode=CreateMode.test)) - body_json = dict(request.json) # type: ignore # 2024-01-24 # TODO: Argument 1 to "dict" has incompatible type "Any | None"; expected "SupportsKeysAndGetItem[Any, Any]" [arg-type] + body_json = request.get_json() + assert isinstance(body_json, dict) body_json["name"] = "mocked_name" # FIXME: BI-4639 try: conn: ConnectionBase = schema.load(body_json) @@ -93,7 +94,7 @@ def post(self): # type: ignore # TODO: fix @ns.route("/test_connection/") class ConnectionTester(BIResource): @schematic_request(ns=ns) - def post(self, connection_id): # type: ignore # TODO: fix + def post(self, connection_id: str) -> None: usm = self.get_us_manager() service_registry = self.get_service_registry() conn = usm.get_by_id(connection_id, expected_type=ConnectionBase) @@ -101,7 +102,8 @@ def post(self, connection_id): # type: ignore # TODO: fix assert isinstance(conn_orig, ConnectionBase) # for typing need_permission_on_entry(conn, USPermissionKind.read) - body_json = dict(request.json) # type: ignore # 2024-01-24 # TODO: Argument 1 to "dict" has incompatible type "Any | None"; expected "SupportsKeysAndGetItem[Any, Any]" [arg-type] + body_json = request.get_json() + assert isinstance(body_json, dict) has_changes = len(body_json.keys()) > 0 if has_changes: @@ -131,7 +133,7 @@ def post(self, connection_id): # type: ignore # TODO: fix class ConnectionsImportList(BIResource): @put_to_request_context(endpoint_code="ConnectionImport") @schematic_request(ns=ns) - def post(self): # type: ignore # TODO: fix + def post(self) -> None: us_manager = self.get_us_manager() notifications = [] @@ -173,7 +175,7 @@ def post(self): # type: ignore # TODO: fix class ConnectionsList(BIResource): @put_to_request_context(endpoint_code="ConnectionCreate") @schematic_request(ns=ns) - def post(self): # type: ignore # TODO: fix + def post(self) -> None: us_manager = self.get_us_manager() conn_availability = self.get_service_registry().get_connector_availability() @@ -229,10 +231,10 @@ def delete(self, connection_id: str) -> None: @put_to_request_context(endpoint_code="ConnectionUpdate") @schematic_request(ns=ns) - def put(self, connection_id): # type: ignore # TODO: fix + def put(self, connection_id: str) -> None: us_manager = self.get_us_manager() - with us_manager.get_locked_entry_cm(ConnectionBase, connection_id) as conn: # type: ignore # TODO: fix + with us_manager.get_locked_entry_cm(ConnectionBase, connection_id) as conn: need_permission_on_entry(conn, USPermissionKind.edit) conn_orig = us_manager.clone_entry_instance(conn) assert isinstance(conn_orig, ConnectionBase) @@ -242,7 +244,9 @@ def put(self, connection_id): # type: ignore # TODO: fix schema = schema_cls(context=schema_ctx) try: - changes = schema.load(request.json) # type: ignore # 2024-01-24 # TODO: Argument 1 to "load" of "Schema" has incompatible type "Any | None"; expected "Mapping[str, Any] | Iterable[Mapping[str, Any]]" [arg-type] + body_json = request.get_json() + assert isinstance(body_json, dict) + changes = schema.load(body_json) schema.update_object(conn, changes) except MValidationError as e: return e.messages, 400 @@ -319,7 +323,7 @@ class ConnectionInfoSources(BIResource): query=ConnectionSourcesQuerySchema(), responses={200: ("Success", ConnectionSourceTemplatesResponseSchema())}, ) - def get(self, connection_id, query): # type: ignore # TODO: fix + def get(self, connection_id: str, query: dict) -> dict: connection = self.get_us_manager().get_by_id(connection_id, expected_type=ConnectionBase) service_registry = self.get_service_registry() @@ -357,7 +361,7 @@ class ConnectionInfoSourceSchema(BIResource): body=ConnectionInfoSourceSchemaQuerySchema(), responses={200: ("Success", ConnectionInfoSourceSchemaResponseSchema())}, ) - def post(self, connection_id: str, body: dict): # type: ignore # TODO: fix + def post(self, connection_id: str, body: dict) -> dict: connection = self.get_us_manager().get_by_id(connection_id, expected_type=ConnectionBase) sr = self.get_service_registry()