mirror of
https://github.com/xfgryujk/blivechat.git
synced 2024-12-26 12:50:33 +08:00
修复一些PyCharm警告
This commit is contained in:
parent
335248c076
commit
6a4faa83a4
17
api/base.py
17
api/base.py
@ -7,6 +7,10 @@ import tornado.web
|
||||
|
||||
# noinspection PyAbstractClass
|
||||
class ApiHandler(tornado.web.RequestHandler):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.json_args = None
|
||||
|
||||
def set_default_headers(self):
|
||||
# 跨域测试用
|
||||
if not self.application.settings['debug']:
|
||||
@ -18,13 +22,12 @@ class ApiHandler(tornado.web.RequestHandler):
|
||||
self.request.headers['Access-Control-Request-Headers'])
|
||||
|
||||
def prepare(self):
|
||||
if self.request.headers.get('Content-Type', '').startswith('application/json'):
|
||||
try:
|
||||
self.json_args = json.loads(self.request.body)
|
||||
except json.JSONDecodeError:
|
||||
self.json_args = None
|
||||
else:
|
||||
self.json_args = None
|
||||
if not self.request.headers.get('Content-Type', '').startswith('application/json'):
|
||||
return
|
||||
try:
|
||||
self.json_args = json.loads(self.request.body)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
async def options(self, *_args, **_kwargs):
|
||||
# 跨域测试用
|
||||
|
@ -121,7 +121,7 @@ class AppConfig:
|
||||
self.translator_configs = translator_configs
|
||||
|
||||
|
||||
def _str_to_list(value, item_type: Type=str, container_type: Type=list):
|
||||
def _str_to_list(value, item_type: Type = str, container_type: Type = list):
|
||||
value = value.strip()
|
||||
if value == '':
|
||||
return container_type()
|
||||
|
1
main.py
1
main.py
@ -60,6 +60,7 @@ def init_logging(debug):
|
||||
file_handler = logging.handlers.TimedRotatingFileHandler(
|
||||
LOG_FILE_NAME, encoding='utf-8', when='midnight', backupCount=7, delay=True
|
||||
)
|
||||
# noinspection PyArgumentList
|
||||
logging.basicConfig(
|
||||
format='{asctime} {levelname} [{name}]: {message}',
|
||||
datefmt='%Y-%m-%d %H:%M:%S',
|
||||
|
@ -25,7 +25,7 @@ _avatar_url_cache: Dict[int, str] = {}
|
||||
# 正在获取头像的Future,user_id -> Future
|
||||
_uid_fetch_future_map: Dict[int, asyncio.Future] = {}
|
||||
# 正在获取头像的user_id队列
|
||||
_uid_queue_to_fetch = None
|
||||
_uid_queue_to_fetch: Optional[asyncio.Queue] = None
|
||||
# 上次被B站ban时间
|
||||
_last_fetch_banned_time: Optional[datetime.datetime] = None
|
||||
|
||||
|
@ -13,7 +13,7 @@ engine = None
|
||||
DbSession: Optional[Type[sqlalchemy.orm.Session]] = None
|
||||
|
||||
|
||||
def init(debug):
|
||||
def init(_debug):
|
||||
cfg = config.get_config()
|
||||
global engine, DbSession
|
||||
# engine = sqlalchemy.create_engine(cfg.database_url, echo=debug)
|
||||
@ -28,7 +28,7 @@ def get_session():
|
||||
session = DbSession()
|
||||
try:
|
||||
yield session
|
||||
except:
|
||||
except BaseException:
|
||||
session.rollback()
|
||||
raise
|
||||
finally:
|
||||
|
@ -23,7 +23,7 @@ NO_TRANSLATE_TEXTS = {
|
||||
}
|
||||
|
||||
_main_event_loop = asyncio.get_event_loop()
|
||||
_http_session = None
|
||||
_http_session: Optional[aiohttp.ClientSession] = None
|
||||
_translate_providers: List['TranslateProvider'] = []
|
||||
# text -> res
|
||||
_translate_cache: Dict[str, str] = {}
|
||||
|
Loading…
Reference in New Issue
Block a user