Skip to content

Commit

Permalink
💥 移除 Python 3.12 以下支持
Browse files Browse the repository at this point in the history
  • Loading branch information
A-kirami committed Oct 23, 2024
1 parent 9825bda commit 2743a0c
Show file tree
Hide file tree
Showing 29 changed files with 107 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: pdm-project/setup-pdm@v3
with:
python-version: '3.10'
python-version: '3.12'
cache: true

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- name: Run Ruff
uses: chartboost/ruff-action@v1
with:
version: 0.3.4
version: 0.7.0
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ ci:
autoupdate_commit_msg: "⬆️ 自动更新预提交挂钩"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
rev: v0.7.0
hooks:
- id: ruff
args: [--fix]
stages: [commit]
stages: [pre-commit]
- id: ruff-format
stages: [commit]
stages: [pre-commit]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<a href="https://pypi.python.org/pypi/kiramibot">
<img src="https://img.shields.io/pypi/v/kiramibot?logo=python&logoColor=edb641" alt="pypi">
</a>
<img src="https://img.shields.io/badge/python-3.10+-blue?logo=python&logoColor=edb641" alt="python">
<img src="https://img.shields.io/badge/python-3.12+-blue?logo=python&logoColor=edb641" alt="python">
<a href="https://github.com/psf/black">
<img src="https://img.shields.io/badge/code%20style-black-000000.svg?logo=python&logoColor=edb641" alt="black">
</a>
Expand Down Expand Up @@ -82,7 +82,7 @@ KiramiBot 是一个功能强大的机器人框架,它可以帮助你创建自
## 🚀 开始

> [!NOTE]
> 需要 Python 3.10 或更高版本,以及 mongoDB 数据库。
> 需要 Python 3.12 或更高版本,以及 mongoDB 数据库。
### 安装 Kirami CLI

Expand Down
6 changes: 2 additions & 4 deletions kirami/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import importlib
from pathlib import Path
from typing import Any, ClassVar, Literal, TypeVar, overload
from typing import Any, ClassVar, Literal, overload

import nonebot
from nonebot.adapters import Adapter, Bot
Expand All @@ -45,8 +45,6 @@
from kirami.version import __metadata__ as __metadata__
from kirami.version import __version__ as __version__

A = TypeVar("A", bound=Adapter)


def get_driver() -> Driver:
"""获取全局`Driver` 实例。
Expand All @@ -71,7 +69,7 @@ def get_adapter(name: str) -> Adapter:


@overload
def get_adapter(name: type[A]) -> A:
def get_adapter[A: Adapter](name: type[A]) -> A:
"""
### 参数
name: 适配器类型
Expand Down
5 changes: 2 additions & 3 deletions kirami/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
from datetime import timedelta
from ipaddress import IPv4Address
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, ClassVar, Literal, NoReturn, TypeAlias
from typing import TYPE_CHECKING, Any, ClassVar, Literal, NoReturn, Self

from mango.drive import DEFAULT_CONNECT_URI
from nonebot.config import Config, Env
from pydantic import BaseModel, Field, IPvAnyAddress, root_validator
from typing_extensions import Self

from .utils import find_plugin

LevelName: TypeAlias = Literal[
type LevelName = Literal[
"TRACE", "DEBUG", "INFO", "SUCCESS", "WARNING", "ERROR", "CRITICAL"
]

Expand Down
6 changes: 1 addition & 5 deletions kirami/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
from pathlib import Path
from typing import Any

import tomllib
from nonebot.plugin import Plugin

try: # pragma: py-gte-311
import tomllib # pyright: ignore[reportMissingImports]
except ModuleNotFoundError: # pragma: py-lt-311
import tomli as tomllib


def load_config() -> dict[str, Any]:
"""加载 KiramiBot 配置。
Expand Down
6 changes: 2 additions & 4 deletions kirami/database/models/group.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from typing import Any, TypeVar
from typing import Any

from mango import Document, Field

T = TypeVar("T")


class Group(Document):
"""群组文档"""
Expand All @@ -13,7 +11,7 @@ class Group(Document):
data: dict[str, Any] = Field(default_factory=dict, init=False)
"""群组数据"""

def get_data(self, name: str, default: T = None) -> T:
def get_data[T](self, name: str, default: T = None) -> T:
return self.data.get(name, default)

async def set_data(self, name: str, value: Any = None) -> None:
Expand Down
6 changes: 2 additions & 4 deletions kirami/database/models/user.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from typing import Any, TypeVar
from typing import Any

from mango import Document, Field

T = TypeVar("T")


class User(Document):
"""用户文档"""
Expand All @@ -13,7 +11,7 @@ class User(Document):
data: dict[str, Any] = Field(default_factory=dict, init=False)
"""用户数据"""

def get_data(self, name: str, default: T = None) -> T:
def get_data[T](self, name: str, default: T = None) -> T:
return self.data.get(name, default)

async def set_data(self, name: str, value: Any = None) -> None:
Expand Down
Loading

0 comments on commit 2743a0c

Please sign in to comment.