From fd5ca6ddbaaa3cecd450da070715fed40d81d685 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Thu, 8 Feb 2024 13:37:29 +0100 Subject: [PATCH] fix mypy errors --- server/cp/ai/semaphore.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/cp/ai/semaphore.py b/server/cp/ai/semaphore.py index 81005fa6..bca1d95a 100644 --- a/server/cp/ai/semaphore.py +++ b/server/cp/ai/semaphore.py @@ -1,6 +1,6 @@ import os import logging -from typing import Optional +from typing import Dict, Optional import requests from requests.exceptions import HTTPError import xml.etree.ElementTree as ET @@ -280,7 +280,9 @@ def convert_to_desired_format(input_data): f"Semaphore Search request failed. We are in analyze RequestError exception: {str(e)}" ) - def create_tag_in_semaphore(self, html_content: str) -> dict: + return {} + + def create_tag_in_semaphore(self, html_content: Dict[str, str]) -> Dict: try: if not self.create_tag_url or not self.api_key: logger.warning( @@ -366,6 +368,7 @@ def create_tag_in_semaphore(self, html_content: str) -> dict: logger.error( f"Semaphore Create Tag Failed failed. We are in analyze RequestError exception: {str(e)}" ) + return {} def data_operation( self, verb: str, operation: str, name: Optional[str], data: dict @@ -374,6 +377,7 @@ def data_operation( return self.analyze(data["item"]) if operation == "search": return self.search(data) + return {} def search(self, data) -> dict: try: @@ -400,7 +404,7 @@ def search(self, data) -> dict: pass return {} - def analyze(self, html_content: dict[str, str], tags=None) -> dict: + def analyze(self, html_content: Dict[str, str], tags=None) -> Dict: try: if not self.base_url or not self.api_key: logger.warning( @@ -540,8 +544,9 @@ def add_to_dict(group, tag_data): except Exception as e: traceback.print_exc() logger.error(f"An error occurred. We are in analyze exception: {str(e)}") + return {} - def html_to_xml(self, html_content: str) -> str: + def html_to_xml(self, html_content: Dict[str, str]) -> str: def clean_html_content(input_str): # Remove full HTML tags using regular expressions your_string = input_str.replace("

", "")