🎨 Improve unnecessary parens after 'not' keyword

This commit is contained in:
洛水居室 2023-05-10 17:36:17 +08:00
parent f3fe7139f7
commit e37a4fb777
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
2 changed files with 4 additions and 2 deletions

View File

@ -182,7 +182,7 @@ class TemplatePreviewer(BaseService, load=application_config.webserver.enable an
@self.web_app.get("/preview/{path:path}")
async def preview_template(path: str, key: Optional[str] = None): # pylint: disable=W0612
# 如果是 /preview/ 开头的静态文件,直接返回内容。比如使用相对链接 ../ 引入的静态资源
if not (path.endswith(".html") ^ path.endswith(".jinja2")):
if not path.endswith((".html", ".jinja2")):
full_path = self.template_service.template_dir / path
if not full_path.is_file():
raise HTTPException(status_code=404, detail=f"Template '{path}' not found")

View File

@ -89,7 +89,9 @@ async def update_metadata_from_github(overwrite: bool = True):
text_map_json_data = {}
async with client.stream("GET", text_map_url) as response:
async for line in response.aiter_lines():
if (string_id := (splits := line.split(":"))[0].strip(' "')) in string_ids:
splits = line.split(":")
string_id = splits[0].strip(' "')
if string_id in string_ids:
text_map_json_data[string_id] = splits[1].strip('\n ,"')
string_ids.remove(string_id)
if not string_ids: