mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-02-03 18:45:32 +08:00
🧑💻 使用 uv 管理项目 (#502)
* 🧑💻 使用 uv 管理项目 * 📝 更新 CONTRIBUTING.md * 🔥 移除 Dependabot * ✨ 修改默认安装的依赖组 * 💚 使用 uv 运行 CI * ➕ 将特殊适配的适配器移动到 dev 依赖组 * 🚨 make mypy happy
This commit is contained in:
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
@@ -1,12 +0,0 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "pip" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
target-branch: "main"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
23
.github/workflows/Release.yml
vendored
23
.github/workflows/Release.yml
vendored
@@ -14,22 +14,23 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
shell: bash
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: astral-sh/setup-uv@v3
|
||||
name: Setup UV
|
||||
with:
|
||||
python-version: '3.11'
|
||||
cache: "poetry"
|
||||
enable-cache: true
|
||||
|
||||
- run: poetry install
|
||||
- name: "Set up Python"
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: ".python-version"
|
||||
|
||||
- run: uv sync
|
||||
shell: bash
|
||||
|
||||
- name: Get Version
|
||||
id: version
|
||||
run: |
|
||||
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
|
||||
echo "VERSION=$(uvx pdm show --version)" >> $GITHUB_OUTPUT
|
||||
echo "TAG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
|
||||
@@ -38,10 +39,10 @@ jobs:
|
||||
run: exit 1
|
||||
|
||||
- name: Build Package
|
||||
run: poetry build
|
||||
run: uv build
|
||||
|
||||
- name: Publish Package to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
run: uv publish
|
||||
|
||||
- name: Publish Package to GitHub Release
|
||||
run: gh release create ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl -t "🔖 ${{ steps.version.outputs.TAG_NAME }}" --generate-notes
|
||||
|
||||
45
.github/workflows/TypeCheck.yml
vendored
45
.github/workflows/TypeCheck.yml
vendored
@@ -1,32 +1,33 @@
|
||||
name: TypeCheck
|
||||
|
||||
on:
|
||||
push:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
TypeCheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
TypeCheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
shell: bash
|
||||
- uses: astral-sh/setup-uv@v3
|
||||
name: Setup UV
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
cache: 'poetry'
|
||||
- name: "Set up Python"
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: ".python-version"
|
||||
|
||||
- run: poetry install
|
||||
shell: bash
|
||||
- run: uv sync
|
||||
shell: bash
|
||||
|
||||
- name: Run Mypy
|
||||
shell: bash
|
||||
run: |
|
||||
poetry run mypy ./nonebot_plugin_tetris_stats
|
||||
- name: Run Mypy
|
||||
shell: bash
|
||||
run: |
|
||||
uv run mypy ./nonebot_plugin_tetris_stats
|
||||
|
||||
- name: Run BasedPyright
|
||||
shell: bash
|
||||
run: |
|
||||
poetry run basedpyright ./nonebot_plugin_tetris_stats/
|
||||
- name: Run BasedPyright
|
||||
shell: bash
|
||||
run: |
|
||||
uv run basedpyright ./nonebot_plugin_tetris_stats/
|
||||
|
||||
1
.python-version
Normal file
1
.python-version
Normal file
@@ -0,0 +1 @@
|
||||
3.10
|
||||
@@ -4,28 +4,19 @@
|
||||
|
||||
### For Developers with Basic Python Knowledge
|
||||
|
||||
First, you need [Python **3.10**](https://www.python.org/) and [Poetry](https://python-poetry.org/).
|
||||
Then, you need to clone this repository to your local machine using the `git clone` command, and install dependencies using `poetry install --sync`.
|
||||
|
||||
### For Developers with Limited Python Knowledge
|
||||
|
||||
Here are **my recommended** best practices:
|
||||
First, you need install [uv](https://docs.astral.sh/uv/).
|
||||
Then:
|
||||
|
||||
```bash
|
||||
# Install uv
|
||||
# Please refer to https://docs.astral.sh/uv/getting-started/installation/
|
||||
|
||||
# Set up the basic Python environment
|
||||
uv python install 3.10
|
||||
uv tool install poetry
|
||||
|
||||
# Clone the repository
|
||||
git clone https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
|
||||
cd nonebot-plugin-tetris-stats
|
||||
|
||||
# Install dependencies
|
||||
uv run --no-project --python 3.10 poetry env use python
|
||||
poetry install --sync
|
||||
uv sync
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
@@ -2,30 +2,19 @@
|
||||
|
||||
## 配置环境
|
||||
|
||||
### 对于有一定 Python 基础的开发者
|
||||
|
||||
首先你需要 [Python **3.10**](https://www.python.org/) 以及 [Poetry](https://python-poetry.org/)。
|
||||
然后你需要使用`git clone`命令将本仓库克隆到本地,然后使用`poetry install --sync`安装依赖。
|
||||
|
||||
### 对于基础不是很好的开发者
|
||||
|
||||
以下是**我认为的**最佳实践:
|
||||
首先你需要安装 [uv](https://docs.astral.sh/uv/)。
|
||||
然后:
|
||||
|
||||
```bash
|
||||
# 安装 uv
|
||||
# 请参考 https://docs.astral.sh/uv/getting-started/installation/
|
||||
|
||||
# 配置基础 Python 环境
|
||||
uv python install 3.10
|
||||
uv tool install poetry
|
||||
|
||||
# 克隆仓库
|
||||
git clone https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
|
||||
cd nonebot-plugin-tetris-stats
|
||||
|
||||
# 安装依赖
|
||||
uv run --no-project --python 3.10 poetry env use python
|
||||
poetry install --sync
|
||||
uv sync
|
||||
```
|
||||
|
||||
## 开发
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from functools import partial
|
||||
from typing import Literal
|
||||
|
||||
from nonebot.compat import PYDANTIC_V2
|
||||
@@ -9,13 +8,9 @@ from ..base import SuccessModel
|
||||
|
||||
if PYDANTIC_V2:
|
||||
from pydantic import field_validator
|
||||
|
||||
custom_validator = partial(field_validator, mode='before')
|
||||
else:
|
||||
from pydantic import validator
|
||||
|
||||
custom_validator = partial(validator, pre=True, always=True) # type: ignore[assignment, arg-type]
|
||||
|
||||
|
||||
class PastInner(BaseModel):
|
||||
season: str
|
||||
@@ -86,12 +81,23 @@ class NeverRatedData(BaseData):
|
||||
percentile: Literal[-1]
|
||||
percentile_rank: Literal['z']
|
||||
|
||||
@custom_validator('apm', 'pps', 'vs')
|
||||
@classmethod
|
||||
def _(cls, value: float | None) -> float:
|
||||
if value is None:
|
||||
return 0
|
||||
return value
|
||||
if PYDANTIC_V2:
|
||||
|
||||
@field_validator('apm', 'pps', 'vs', mode='before')
|
||||
@classmethod
|
||||
def _(cls, value: float | None) -> float:
|
||||
if value is None:
|
||||
return 0
|
||||
return value
|
||||
|
||||
else:
|
||||
|
||||
@validator('apm', 'pps', 'vs', pre=True, always=True)
|
||||
@classmethod
|
||||
def _(cls, value: float | None) -> float:
|
||||
if value is None:
|
||||
return 0
|
||||
return value
|
||||
|
||||
|
||||
class RatedData(BaseData):
|
||||
|
||||
4318
poetry.lock
generated
4318
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
248
pyproject.toml
248
pyproject.toml
@@ -1,145 +1,153 @@
|
||||
[tool.poetry]
|
||||
name = 'nonebot-plugin-tetris-stats'
|
||||
[project]
|
||||
name = "nonebot-plugin-tetris-stats"
|
||||
version = "1.5.5"
|
||||
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
|
||||
authors = ['scdhh <wallfjjd@gmail.com>']
|
||||
readme = 'README.md'
|
||||
homepage = 'https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats'
|
||||
repository = 'https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats'
|
||||
license = 'AGPL-3.0'
|
||||
description = "一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件"
|
||||
readme = "README.md"
|
||||
authors = [{ name = "shoucandanghehe", email = "wallfjjd@gmail.com" }]
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
"aiocache>=0.12.3",
|
||||
"aiofiles>=24.1.0",
|
||||
"arclet-alconna<2",
|
||||
"async-lru>=2.0.4",
|
||||
"httpx>=0.27.2",
|
||||
"jinja2>=3.1.4",
|
||||
"lxml>=5.3.0",
|
||||
"msgspec>=0.18.6",
|
||||
"nonebot-plugin-alconna>=0.53.1",
|
||||
"nonebot-plugin-apscheduler>=0.5.0",
|
||||
"nonebot-plugin-localstore>=0.7.1",
|
||||
"nonebot-plugin-orm>=0.7.6",
|
||||
"nonebot-plugin-session>=0.3.2",
|
||||
"nonebot-plugin-session-orm>=0.2.0",
|
||||
"nonebot-plugin-user>=0.4.4",
|
||||
"nonebot-plugin-userinfo>=0.2.6",
|
||||
"nonebot2[fastapi]>=2.3.3",
|
||||
"pandas>=2.2.3",
|
||||
"pillow>=11.0.0",
|
||||
"playwright>=1.48.0",
|
||||
"rich>=13.9.3",
|
||||
"yarl>=1.16.0",
|
||||
]
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
]
|
||||
keywords = ["nonebot2"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = '^3.10'
|
||||
nonebot2 = { extras = ['fastapi'], version = '^2.3.0' }
|
||||
nonebot-plugin-alconna = '>=0.48.0'
|
||||
nonebot-plugin-apscheduler = '>=0.4,<0.6'
|
||||
nonebot-plugin-localstore = '>=0.6,<0.8'
|
||||
nonebot-plugin-orm = '>=0.1.1,<0.8.0'
|
||||
nonebot-plugin-session = '^0.3.1'
|
||||
nonebot-plugin-session-orm = '^0.2.0'
|
||||
nonebot-plugin-user = '>=0.2,<0.5'
|
||||
nonebot-plugin-userinfo = '^0.2.4'
|
||||
aiocache = '^0.12.2'
|
||||
aiofiles = '>=23.2.1,<25.0.0'
|
||||
arclet-alconna = '<2.0.0'
|
||||
async-lru = '^2.0.4'
|
||||
httpx = '^0.27.0'
|
||||
jinja2 = '^3.1.3'
|
||||
lxml = '^5.1.0'
|
||||
msgspec = '^0.18.6'
|
||||
pandas = '>=1.4.3,<3.0.0'
|
||||
pillow = '>=10.3,<12.0'
|
||||
playwright = '^1.41.2'
|
||||
rich = '^13.7.1'
|
||||
yarl = '^1.9.4'
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
basedpyright = '^1.17.0'
|
||||
mypy = '>=1.9'
|
||||
pandas-stubs = '>=1.5.2,<3.0.0'
|
||||
ruff = '>=0.3.0'
|
||||
types-aiofiles = '>=23.2.0.20240106,<25.0.0.0'
|
||||
types-lxml = '^2024.2.9'
|
||||
types-pillow = '^10.2.0.20240423'
|
||||
types-ujson = '^5.9.0'
|
||||
nonebot2 = { extras = ['all'], version = '^2.3.0' }
|
||||
nonebot-adapter-discord = '^0.1.3'
|
||||
nonebot-adapter-kaiheila = '^0.3.4'
|
||||
nonebot-adapter-onebot = '^2.4.1'
|
||||
nonebot-adapter-qq = '^1.4.4'
|
||||
nonebot-adapter-satori = '>=0.11.4,<0.13.0'
|
||||
nonebot-plugin-orm = { extras = ['default'], version = '>=0.3,<0.8' }
|
||||
|
||||
[tool.poetry.group.debug.dependencies]
|
||||
matplotlib = '^3.9.2'
|
||||
memory-profiler = '^0.61.0'
|
||||
objprint = '^0.2.2'
|
||||
pyqt6 = '^6.7.1'
|
||||
viztracer = '>=0.16.2,<0.18.0'
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/A-Minos/nonebot-plugin-tetris-stats"
|
||||
Repository = "https://github.com/A-Minos/nonebot-plugin-tetris-stats"
|
||||
Issues = "https://github.com/A-Minos/nonebot-plugin-tetris-stats/issues"
|
||||
|
||||
[build-system]
|
||||
requires = ['poetry-core>=1.0.0']
|
||||
build-backend = 'poetry.core.masonry.api'
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"basedpyright>=1.19.1",
|
||||
"mypy>=1.13.0",
|
||||
"nonebot-adapter-discord>=0.1.8",
|
||||
"nonebot-adapter-kaiheila>=0.3.4",
|
||||
"nonebot-adapter-onebot>=2.4.6",
|
||||
"nonebot-adapter-qq>=1.5.3",
|
||||
"ruff>=0.7.1",
|
||||
]
|
||||
typecheck = [
|
||||
"pandas-stubs>=2.2.3.241009",
|
||||
"types-aiofiles>=24.1.0.20240626",
|
||||
"types-lxml>=2024.9.16",
|
||||
"types-pillow>=10.2.0.20240822",
|
||||
]
|
||||
test = ["nonebot-adapter-satori>=0.12.6", "nonebot-plugin-orm[default]>=0.7.6", "nonebot2[aiohttp,fastapi]>=2.3.3"]
|
||||
debug = ["matplotlib>=3.9.2", "memory-profiler>=0.61.0", "objprint>=0.2.3", "pyqt6>=6.7.1", "viztracer>=0.17.0"]
|
||||
|
||||
[tool.uv]
|
||||
default-groups = ["dev", "typecheck"]
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
target-version = 'py310'
|
||||
target-version = "py310"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
'F', # pyflakes
|
||||
'E', # pycodestyle errors
|
||||
'W', # pycodestyle warnings
|
||||
'C90', # mccabe
|
||||
'I', # isort
|
||||
'N', # PEP8-naming
|
||||
'UP', # pyupgrade
|
||||
'YTT', # flake8-2020
|
||||
'ANN', # flake8-annotations
|
||||
'ASYNC', # flake8-async
|
||||
'S', # flake8-bandit
|
||||
'BLE', # flake8-blind-except
|
||||
'FBT', # flake8-boolean-trap
|
||||
'B', # flake8-bugbear
|
||||
'A', # flake8-builtins
|
||||
'COM', # flake8-commas
|
||||
'C4', # flake8-comprehensions
|
||||
'DTZ', # flake8-datetimez
|
||||
'T10', # flake8-debugger
|
||||
'EM', # flake8-errmsg
|
||||
'FA', # flake8-future-annotations
|
||||
'ISC', # flake8-implicit-str-concat
|
||||
'ICN', # flake8-import-conventions
|
||||
'PIE', # flake8-pie
|
||||
'T20', # flake8-print
|
||||
'PYI', # flake8-pyi
|
||||
'Q', # flake8-quotes
|
||||
'RSE', # flake8-raise
|
||||
'RET', # flake8-return
|
||||
'SLF', # flake8-self
|
||||
'SLOT', # flake8-slots
|
||||
'SIM', # flake8-simplify
|
||||
'TID', # flake8-tidy-imports
|
||||
'TCH', # flake8-type-checking
|
||||
'ARG', # flake8-unused-arguments
|
||||
'PTH', # flake8-use-pathlib
|
||||
'ERA', # eradicate
|
||||
'PD', # pandas-vet
|
||||
'PGH', # pygrep-hooks
|
||||
'PL', # pylint
|
||||
'TRY', # tryceratops
|
||||
'FLY', # flynt
|
||||
'FAST', # FastAPI
|
||||
'PERF', # Perflint
|
||||
'FURB', # refurb
|
||||
'RUF', # Ruff-specific rules
|
||||
"F", # pyflakes
|
||||
"E", # pycodestyle errors
|
||||
"W", # pycodestyle warnings
|
||||
"C90", # mccabe
|
||||
"I", # isort
|
||||
"N", # PEP8-naming
|
||||
"UP", # pyupgrade
|
||||
"YTT", # flake8-2020
|
||||
"ANN", # flake8-annotations
|
||||
"ASYNC", # flake8-async
|
||||
"S", # flake8-bandit
|
||||
"BLE", # flake8-blind-except
|
||||
"FBT", # flake8-boolean-trap
|
||||
"B", # flake8-bugbear
|
||||
"A", # flake8-builtins
|
||||
"COM", # flake8-commas
|
||||
"C4", # flake8-comprehensions
|
||||
"DTZ", # flake8-datetimez
|
||||
"T10", # flake8-debugger
|
||||
"EM", # flake8-errmsg
|
||||
"FA", # flake8-future-annotations
|
||||
"ISC", # flake8-implicit-str-concat
|
||||
"ICN", # flake8-import-conventions
|
||||
"PIE", # flake8-pie
|
||||
"T20", # flake8-print
|
||||
"PYI", # flake8-pyi
|
||||
"Q", # flake8-quotes
|
||||
"RSE", # flake8-raise
|
||||
"RET", # flake8-return
|
||||
"SLF", # flake8-self
|
||||
"SLOT", # flake8-slots
|
||||
"SIM", # flake8-simplify
|
||||
"TID", # flake8-tidy-imports
|
||||
"TCH", # flake8-type-checking
|
||||
"ARG", # flake8-unused-arguments
|
||||
"PTH", # flake8-use-pathlib
|
||||
"ERA", # eradicate
|
||||
"PD", # pandas-vet
|
||||
"PGH", # pygrep-hooks
|
||||
"PL", # pylint
|
||||
"TRY", # tryceratops
|
||||
"FLY", # flynt
|
||||
"FAST", # FastAPI
|
||||
"PERF", # Perflint
|
||||
"FURB", # refurb
|
||||
"RUF", # Ruff-specific rules
|
||||
]
|
||||
ignore = [
|
||||
'E501', # 过长的行由 ruff format 处理, 剩余的都是字符串
|
||||
'ANN101', # 由 type checker 自动推断
|
||||
'ANN102', # 由 type checker 自动推断
|
||||
'ANN202', # 向 NoneBot 注册的函数
|
||||
'TRY003',
|
||||
'COM812', # 强制尾随逗号
|
||||
'TID252', # 相对导入
|
||||
'ISC001', # format warning
|
||||
"E501", # 过长的行由 ruff format 处理, 剩余的都是字符串
|
||||
"ANN101", # 由 type checker 自动推断
|
||||
"ANN102", # 由 type checker 自动推断
|
||||
"ANN202", # 向 NoneBot 注册的函数
|
||||
"TRY003",
|
||||
"COM812", # 强制尾随逗号
|
||||
"TID252", # 相对导入
|
||||
"ISC001", # format warning
|
||||
]
|
||||
flake8-quotes = { inline-quotes = 'single', multiline-quotes = 'double' }
|
||||
flake8-quotes = { inline-quotes = "single", multiline-quotes = "double" }
|
||||
|
||||
[tool.ruff.lint.flake8-annotations]
|
||||
mypy-init-return = true
|
||||
|
||||
[tool.ruff.lint.flake8-builtins]
|
||||
builtins-ignorelist = ['id']
|
||||
builtins-ignorelist = ["id"]
|
||||
|
||||
[tool.ruff.format]
|
||||
quote-style = 'single'
|
||||
quote-style = "single"
|
||||
|
||||
[tool.basedpyright]
|
||||
pythonVersion = '3.10'
|
||||
pythonPlatform = 'All'
|
||||
pythonVersion = "3.10"
|
||||
pythonPlatform = "All"
|
||||
defineConstant = { PYDANTIC_V2 = true }
|
||||
typeCheckingMode = 'standard'
|
||||
typeCheckingMode = "standard"
|
||||
|
||||
[tool.nonebot]
|
||||
plugins = ['nonebot_plugin_tetris_stats']
|
||||
plugins = ["nonebot_plugin_tetris_stats"]
|
||||
|
||||
Reference in New Issue
Block a user