Skip to content

Commit

Permalink
fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Feb 8, 2024
1 parent dc44579 commit fd5ca6d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions server/cp/ai/semaphore.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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("<p>", "")
Expand Down

0 comments on commit fd5ca6d

Please sign in to comment.