Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Colsrch committed Sep 24, 2023
1 parent 71a3f96 commit ab9f1f3
Show file tree
Hide file tree
Showing 6 changed files with 657 additions and 636 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
rev: 'v0.0.290'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: [--fix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand Down
6 changes: 3 additions & 3 deletions app/plugin/basic/__10_mc_info/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ def _pack_varint(data):

def _pack_data(self, data):
"""Page the data"""
if type(data) is str:
if isinstance(data, str):
data = data.encode("utf8")
return self._pack_varint(len(data)) + data
elif type(data) is int:
elif isinstance(data, int):
return struct.pack("H", data)
elif type(data) is float:
elif isinstance(data, float):
return struct.pack("Q", int(data))
else:
return data
Expand Down
2 changes: 1 addition & 1 deletion app/util/baidu_ai/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def image_moderation_async(image: Union[str, bytes]) -> dict:
if not Config.baidu_ai.moderation.enable:
logger.warning("百度内容审核未启用")
return {"status": False, "message": "百度内容审核未启用"}
if type(image) == str:
if isinstance(image, str):
try:
image = await general_request(image, _type="bytes")
except InvalidURL as e:
Expand Down
2 changes: 1 addition & 1 deletion app/util/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def isstartswith(prefix: str, args: Union[str, list], full_match=False) -> bool:
:param args: 匹配元素
:param full_match: 完全匹配
"""
if type(args) == str:
if isinstance(args, str):
args = [args]
return any(full_match and prefix == arg or not full_match and prefix.startswith(arg) for arg in args)

Expand Down
Loading

0 comments on commit ab9f1f3

Please sign in to comment.