Skip to content

Commit

Permalink
Revert "Fix:(#381) Remove redundant typing. Adding support for Python…
Browse files Browse the repository at this point in the history
… < 3.10 and >3.8 (#387)"

This reverts commit 33d9a25.
  • Loading branch information
Samueli924 committed Nov 14, 2024
1 parent 0a9b938 commit e35d2db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/answer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import configparser
import requests
from pathlib import Path
from typing import Optional
import json
from api.logger import logger
import random
Expand All @@ -19,7 +20,7 @@ def __init__(self, file: str = "cache.json"):
self.cacheFile.open("w").write("{}")
self.fp = self.cacheFile.open("r+", encoding="utf8")

def getCache(self, question: str):
def getCache(self, question: str) -> Optional[str]:
self.fp.seek(0)
data = json.load(self.fp)
if isinstance(data, dict):
Expand Down Expand Up @@ -82,7 +83,7 @@ def _init_tiku(self):
# 仅用于题库初始化,例如配置token,交由自定义题库完成
pass

def config_set(self,config):
def config_set(self,config:configparser.ConfigParser|None):
self._conf = config

def _get_conf(self):
Expand All @@ -98,7 +99,7 @@ def _get_conf(self):
self.DISABLE = True
return None

def query(self,q_info:dict):
def query(self,q_info:dict) -> str|None:
if self.DISABLE:
return None

Expand Down

0 comments on commit e35d2db

Please sign in to comment.