diff --git a/.github/workflows/pyright.yml b/.github/workflows/pyright.yml new file mode 100644 index 00000000..752d900c --- /dev/null +++ b/.github/workflows/pyright.yml @@ -0,0 +1,26 @@ +name: Pyright Lint + +on: + push: + branches: + - master + pull_request: + paths: + - "nonebot/**" + - "packages/**" + - "tests/**" + +jobs: + pyright: + name: Pyright Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Python environment + uses: ./.github/actions/setup-python + + - run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH + + - name: Run Pyright + uses: jakebailey/pyright-action@v1 diff --git a/README.md b/README.md index d322f3c9..12a1558f 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,19 @@ _✨ 跨平台 Python 异步机器人框架 ✨_ license - pypi + pypi - python + python + + black + + + pyright + + + ruff + +
codecov @@ -31,6 +41,12 @@ _✨ 跨平台 Python 异步机器人框架 ✨_ pre-commit + + pyright + + + ruff +
onebot diff --git a/nonebot/plugin/on.pyi b/nonebot/plugin/on.pyi index 07aa95be..b5808a49 100644 --- a/nonebot/plugin/on.pyi +++ b/nonebot/plugin/on.pyi @@ -1,4 +1,5 @@ import re +from typing import Any from types import ModuleType from datetime import datetime, timedelta @@ -177,10 +178,10 @@ def on_type( class _Group: matchers: list[type[Matcher]] = ... - base_kwargs: dict[str, ...] = ... + base_kwargs: dict[str, Any] = ... def _get_final_kwargs( - self, update: dict[str, ...], *, exclude: set[str, ...] | None = None - ) -> dict[str, ...]: ... + self, update: dict[str, Any], *, exclude: set[str] | None = None + ) -> dict[str, Any]: ... class CommandGroup(_Group): basecmd: tuple[str, ...] = ... diff --git a/package.json b/package.json index 758e0f16..fdefbf5c 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,12 @@ "start": "yarn workspace nonebot start", "serve": "yarn workspace nonebot serve", "clear": "yarn workspace nonebot clear", - "prettier": "prettier --config ./.prettierrc --write \"./website/\"" + "prettier": "prettier --config ./.prettierrc --write \"./website/\"", + "pyright": "pyright" }, "devDependencies": { "cross-env": "^7.0.3", - "prettier": "^2.5.0" + "prettier": "^2.5.0", + "pyright": "^1.1.317" } } diff --git a/pyproject.toml b/pyproject.toml index 8b9fd96e..58159a99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,6 @@ fixture-parentheses = false mark-parentheses = false [tool.pyright] -reportShadowedImports = false pythonVersion = "3.8" pythonPlatform = "All" executionEnvironments = [ @@ -112,6 +111,9 @@ executionEnvironments = [ { root = "./" }, ] +typeCheckingMode = "basic" +reportShadowedImports = false + [build-system] requires = ["poetry_core>=1.0.0"] diff --git a/yarn.lock b/yarn.lock index bdf67154..4dfa02ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6219,6 +6219,11 @@ pupa@^2.1.1: dependencies: escape-goat "^2.0.0" +pyright@^1.1.317: + version "1.1.317" + resolved "https://registry.npmjs.org/pyright/-/pyright-1.1.317.tgz#753ac481e2b9c9e2a7b9faf6e2a49a1dc1c73806" + integrity sha512-3tGq//Nmqfp8IDuFfQwF18dqDBq5SRo/OPBJLiW0p+VwDVSth1LS1fBrMy/u14Mqcdi7C+ARVnxXTBCpczZahg== + q@^1.1.2: version "1.5.1" resolved "https://registry.npmjs.org/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"