-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
163 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
default_install_hook_types: [pre-commit, prepare-commit-msg] | ||
ci: | ||
autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks" | ||
autofix_prs: true | ||
autoupdate_branch: dev | ||
autoupdate_schedule: weekly | ||
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks" | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.5.6 | ||
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: 24.8.0 | ||
hooks: | ||
- id: black | ||
stages: [commit] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v4.0.0-alpha.8 | ||
hooks: | ||
- id: prettier | ||
types_or: [javascript, jsx, ts, tsx, markdown, yaml, json] | ||
stages: [commit] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ version = "0.1.1" | |
description = "基于 Nonebot2 和 go-cqhttp 开发,以 postgresql 作为数据库,非常可爱的绪山真寻bot" | ||
authors = ["HibiKier <[email protected]>"] | ||
license = "AGPL" | ||
package-mode = false | ||
|
||
[[tool.poetry.source]] | ||
name = "ali" | ||
|
@@ -15,7 +16,7 @@ python = "^3.10" | |
playwright = "^1.41.1" | ||
nonebot-adapter-onebot = "^2.3.1" | ||
nonebot-plugin-apscheduler = "^0.3.0" | ||
tortoise-orm = {extras = ["asyncpg"], version = "^0.20.0"} | ||
tortoise-orm = { extras = ["asyncpg"], version = "^0.20.0" } | ||
cattrs = "^23.2.3" | ||
ruamel-yaml = "^0.18.5" | ||
strenum = "^0.4.15" | ||
|
@@ -43,11 +44,94 @@ cn2an = "^0.5.22" | |
aiohttp = "^3.9.5" | ||
dateparser = "^1.2.0" | ||
bilireq = "0.2.3post0" | ||
python-jose = {extras = ["cryptography"], version = "^3.3.0"} | ||
python-jose = { extras = ["cryptography"], version = "^3.3.0" } | ||
python-multipart = "^0.0.9" | ||
nonebot-plugin-alconna = "^0.51.1" | ||
|
||
[tool.poetry.dev-dependencies] | ||
nonebug = "^0.3.2" | ||
pytest-cov = "^5.0.0" | ||
pytest-mock = "^3.6.1" | ||
pytest-asyncio = "^0.23.5" | ||
pytest-xdist = "^3.3.1" | ||
respx = "^0.21.1" | ||
|
||
[tool.nonebot] | ||
plugins = [ | ||
"nonebot_plugin_apscheduler", | ||
"nonebot_plugin_session", | ||
"nonebot_plugin_htmlrender", | ||
"nonebot_plugin_userinfo", | ||
"nonebot_plugin_alconna", | ||
] | ||
plugin_dirs = ["zhenxun/services", "zhenxun/builtin_plugins", "zhenxun/plugins"] | ||
adapters = [ | ||
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" }, | ||
{ name = "DoDo", module_name = "nonebot.adapters.dodo" }, | ||
{ name = "开黑啦", module_name = "nonebot.adapters.kaiheila" }, | ||
] | ||
|
||
[tool.black] | ||
line-length = 88 | ||
target-version = ["py39", "py310", "py311", "py312"] | ||
include = '\.pyi?$' | ||
extend-exclude = ''' | ||
''' | ||
|
||
[tool.isort] | ||
profile = "black" | ||
line_length = 88 | ||
length_sort = true | ||
skip_gitignore = true | ||
force_sort_within_sections = true | ||
src_paths = ["zhenxun", "tests"] | ||
extra_standard_library = ["typing_extensions"] | ||
|
||
[tool.ruff] | ||
line-length = 88 | ||
target-version = "py310" | ||
|
||
[tool.ruff.lint] | ||
select = [ | ||
"F", # Pyflakes | ||
"W", # pycodestyle warnings | ||
"E", # pycodestyle errors | ||
"UP", # pyupgrade | ||
"ASYNC", # flake8-async | ||
"C4", # flake8-comprehensions | ||
"T10", # flake8-debugger | ||
"T20", # flake8-print | ||
"PYI", # flake8-pyi | ||
"PT", # flake8-pytest-style | ||
"Q", # flake8-quotes | ||
"RUF", # Ruff-specific rules | ||
] | ||
ignore = [ | ||
"E402", # module-import-not-at-top-of-file | ||
"UP037", # quoted-annotation | ||
"RUF001", # ambiguous-unicode-character-string | ||
"RUF002", # ambiguous-unicode-character-docstring | ||
"RUF003", # ambiguous-unicode-character-comment | ||
] | ||
|
||
[tool.ruff.lint.flake8-pytest-style] | ||
fixture-parentheses = false | ||
mark-parentheses = false | ||
|
||
[tool.pyright] | ||
pythonVersion = "3.9" | ||
pythonPlatform = "All" | ||
defineConstant = { PYDANTIC_V2 = true } | ||
executionEnvironments = [ | ||
{ root = "./tests", extraPaths = [ | ||
"./", | ||
] }, | ||
{ root = "./" }, | ||
] | ||
|
||
typeCheckingMode = "standard" | ||
reportShadowedImports = false | ||
disableBytesTypePromotions = true | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
|
||
import nonebot | ||
import pytest | ||
from nonebot.plugin import Plugin | ||
from nonebug import NONEBOT_INIT_KWARGS | ||
from nonebug.app import App | ||
from pytest_mock import MockerFixture | ||
from respx import MockRouter | ||
|
||
|
||
def pytest_configure(config: pytest.Config) -> None: | ||
config.stash[NONEBOT_INIT_KWARGS] = { | ||
"driver": "~fastapi+~httpx+~websockets", | ||
"superusers": ["AkashiCoin"], | ||
"command_start": "", | ||
"session_running_expression": "别急呀,小真寻要宕机了!QAQ", | ||
"image_to_bytes": False, | ||
"nickname": ["真寻", "小真寻", "绪山真寻", "小寻子"], | ||
"session_expire_timeout": 30, | ||
"self_nickname": "小真寻", | ||
"db_url": "sqlite://:memory:", | ||
"platform_superusers": {"qq": ["qq_su"], "dodo": ["dodo_su"]}, | ||
"host": "127.0.0.1", | ||
"port": 8080, | ||
} | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def load_plugin(nonebug_init: None) -> set[Plugin]: | ||
return nonebot.load_plugins("zhenxun.plugins") | ||
|
||
|
||
@pytest.fixture | ||
async def app(app: App, tmp_path: Path, mocker: MockerFixture): | ||
mocker.patch("nonebot.drivers.websockets.connect", return_value=MockRouter()) | ||
return app |