Skip to content

Commit

Permalink
style: use ruff-format (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeetWq committed Feb 29, 2024
1 parent b6755d3 commit 90dca22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
15 changes: 2 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,12 @@ ci:
autoupdate_commit_msg: "chore: auto update by pre-commit hooks"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
stages: [commit]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
stages: [commit]

- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
stages: [commit]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
Expand Down
3 changes: 2 additions & 1 deletion nonebot_plugin_chatrecorder/adapters/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ async def record_send_msg(
message += MessageSegment.emoji(elem.name)
else:
message += MessageSegment(
type=elem.__class__.__name__.lower(), data=asdict(elem) # type: ignore
type=elem.__class__.__name__.lower(),
data=asdict(elem), # type: ignore
)

record = MessageRecord(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def _migrate_old_data(ds_conn: Connection):
)
raise RuntimeError("chatrecorder: 请先安装 0.4.2 版本完成迁移之后再升级")

logger.warning("chatrecorder: 发现来自 datastore 的数据,正在迁移,请不要关闭程序...")
logger.warning(
"chatrecorder: 发现来自 datastore 的数据,正在迁移,请不要关闭程序..."
)
logger.info(f"chatrecorder: 聊天记录数据总数:{count}")

# 每次迁移的数据量为 10000 条
Expand Down Expand Up @@ -97,7 +99,9 @@ def _migrate_old_data(ds_conn: Connection):
}
)
session.execute(insert(MessageRecord), bulk_insert_records)
logger.info(f"chatrecorder: 已迁移 {i * migration_limit + len(records)}/{count}")
logger.info(
f"chatrecorder: 已迁移 {i * migration_limit + len(records)}/{count}"
)

session.commit()
logger.warning("chatrecorder: 聊天记录数据迁移完成!")
Expand Down
15 changes: 9 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ optional = true
[tool.poetry.group.adapters.dependencies]
nonebot-adapter-onebot = "^2.2.4"
nonebot-adapter-console = "^0.4.0"
nonebot-adapter-qqguild = "^0.2.5"
nonebot-adapter-kaiheila = "^0.2.12"
nonebot-adapter-telegram = "^0.1.0b14"
nonebot-adapter-feishu = "^2.2.0"
nonebot-adapter-red = "^0.7.4"
nonebot-adapter-discord = "^0.1.0b4"
nonebot-adapter-dodo = "^0.1.3"
nonebot-adapter-villa = "^1.2.2"
nonebot-adapter-satori = "^0.8.0"

[tool.pytest.ini_options]
Expand All @@ -51,14 +49,19 @@ asyncio_mode = "auto"
[tool.nonebot]
plugins = ["nonebot_plugin_chatrecorder"]

[tool.isort]
profile = "black"
skip_gitignore = true

[tool.ruff]
line-length = 88
target-version = "py38"

[tool.ruff.lint]
select = ["E", "W", "F", "UP", "C", "T", "PYI", "Q"]
ignore = ["E402", "E501", "E711", "C901", "UP037"]

[tool.pyright]
pythonVersion = "3.8"
pythonPlatform = "All"
typeCheckingMode = "basic"

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
Expand Down

0 comments on commit 90dca22

Please sign in to comment.