Skip to content

Commit

Permalink
[All] Bumped to 3.1.2
Browse files Browse the repository at this point in the history
* [OneBot] It's possible to provide HTTP service address flexibly

* [All] Use new formatting args & removed deprecated items

* [All] No longer using the pylint

* [melobot] Update version flag

* [Docs] Added missing data element references

* [melobot] Moved plugin share object loading logics to inner module

* [Docs] Fix doc typo in FlagMixin method return value

* [melobot] "two_steam" now also write warning logs into error log files

* [OneBot] Fix OneBot Customize segment type hint errors

* [Docs] Updated docs for 3.1.2
  • Loading branch information
aicorein authored Feb 23, 2025
1 parent 2957610 commit 3357356
Show file tree
Hide file tree
Showing 59 changed files with 270 additions and 1,408 deletions.
669 changes: 0 additions & 669 deletions .pylintrc

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<p>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://mypy-lang.org/"><img src="https://www.mypy-lang.org/static/mypy_badge.svg" alt="Checked with mypy"></a>
<a href="https://github.com/pylint-dev/pylint"><img src="https://img.shields.io/badge/Pylint-checked-blue" alt="Pylint - checked"></a>
</p>
</div>

Expand Down
5 changes: 0 additions & 5 deletions docs/source/api/melobot.handle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,3 @@ melobot.handle
.. autofunction:: melobot.handle.get_event

.. autofunction:: melobot.handle.try_get_event

弃用项,临时存在
----------------

.. autofunction:: melobot.handle.GetParseArgs
8 changes: 8 additions & 0 deletions docs/source/api/melobot.typ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ melobot.typ

泛型 T,无约束

.. data:: melobot.typ.U

泛型 U,无约束

.. data:: melobot.typ.V

泛型 V,无约束

.. data:: melobot.typ.T_co

泛型 T_co,协变无约束
Expand Down
12 changes: 8 additions & 4 deletions docs/source/intro/msg-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,29 @@ async def _():
如何让 melobot 发送这种自定义的消息段?非常简单:

```python
from melobot.protocols.onebot.v11.adapter.segment import Segment
from melobot.protocols.onebot.v11 import Segment
# 临时构造自定义消息段
seg = Segment(type="touch", id="1574260633")
```

或者构造一种新的消息段类型:

```python
from melobot.protocols.onebot.v11.adapter.segment import Segment
from typing import Literal, TypedDict
from melobot.protocols.onebot.v11 import CustomSegCls, Segment
from typing_extensions import Literal, TypedDict

class _TouchData(TypedDict):
id: str

# 返回新类型 TouchSegment
# 后续事件的消息段创建过程,会自动将对应消息段初始化为 TouchSegment 类型
TouchSegment = Segment.add_type(Literal['touch'], _TouchData)
TouchSegment: type[CustomSegCls[Literal['touch'], _TouchData]] = \
Segment.add_type(Literal['touch'], _TouchData)
# 使用新的消息段类型来构造:
seg = TouchSegment(id="1574260633")
# 对象的这些属性拥有类型注解:
s.type # Literal['touch']
s.data # _TouchData
```

## 单条消息的其他发送方法
Expand Down
22 changes: 22 additions & 0 deletions docs/source/update-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ def f(s): print(f"([{s[-40:][:7]}]({s[:-33]}))")

# 更新日志

## v3.1.2

### ⏩变更

- [core] 移除所有原本预计在 `3.1.1` 版本移除的组件 ([4b14ed5](https://github.com/Meloland/melobot/commit/4b14ed5))

- [core] 内置日志器现在启用 `two_steam`,warning 级别的日志也将被分流到 `xxxxx.err.log` 中 ([8a2f1d7](https://github.com/Meloland/melobot/commit/8a2f1d7))

- [core] 更新了插件共享对象获取的逻辑,无需更新任何代码。但新的插件初始化过程生成的 `__init__.py` 将采用新的运行逻辑 ([a207f27](https://github.com/Meloland/melobot/commit/a207f27))

- [OneBot] 现在 {class}`~.v11.io.HttpIO` 的初始化参数 `onebot_host``onebot_port` 已移除,改为使用 `onebot_url`。这有利于更自由的提供 http 服务的 url ([5a2cbb6](https://github.com/Meloland/melobot/commit/5a2cbb6))

### 👍修复

- [OneBot] 修复创建自定义消息段类型的方法 {meth}`~.Segment.add_type` 的类型注解问题,并更新了相关文档 ([e2175d1](https://github.com/Meloland/melobot/commit/e2175d1))。无需更新任何代码。文档被更新处:[自定义消息段的构造](https://docs.melobot.org/intro/msg-action.html#id3)

- [Docs] 文档笔误修复 ([23076b8](https://github.com/Meloland/melobot/commit/23076b8), [b37874e](https://github.com/Meloland/melobot/commit/b37874e))

### ⚙️ 内部

- [core] 开发项目时不再使用 pylint 监测代码质量 ([1b49dfb](https://github.com/Meloland/melobot/commit/1b49dfb))

## v3.1.1

### ⏩变更
Expand Down
64 changes: 2 additions & 62 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 28 additions & 42 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
name = "melobot"
dynamic = ["version"]
description = "A bot framework with much high level features."
authors = [
{name = "aicorein", email = "[email protected]"},
]
maintainers = [
{name = "aicorein", email = "[email protected]"}
]
authors = [{ name = "aicorein", email = "[email protected]" }]
maintainers = [{ name = "aicorein", email = "[email protected]" }]
dependencies = [
"better-exceptions==0.3.3",
"rich>=13.7.1,<14",
Expand All @@ -17,7 +13,7 @@ dependencies = [
]
requires-python = ">=3.10"
readme = "README.md"
license = {text = "BSD"}
license = { text = "BSD" }
keywords = ["melobot", "bot framework", "asyncio", "coroutine", "concurrency"]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -33,7 +29,7 @@ classifiers = [
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed"
"Typing :: Typed",
]


Expand All @@ -44,14 +40,8 @@ Repository = "https://github.com/Meloland/melobot.git"
Issues = "https://github.com/Meloland/melobot/issues"

[project.optional-dependencies]
onebot = [
"pydantic>=2.9.2,<3",
"websockets>=14.1,<15",
"aiohttp>=3.10.10,<4",
]
cli = [
"watchdog>=6.0.0,<7",
]
onebot = ["pydantic>=2.9.2,<3", "websockets>=14.1,<15", "aiohttp>=3.10.10,<4"]
cli = ["watchdog>=6.0.0,<7"]
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
Expand All @@ -67,44 +57,40 @@ warn_redundant_casts = true
disallow_untyped_calls = true
strict_equality = true

[tool.black]
line-length = 90
[tool.black]
line-length = 100

[tool.isort]
[tool.isort]
profile = "black"
line_length = 90
line_length = 100

[tool.pdm]
distribution = true
version = { source = "file", path = "src/melobot/_meta.py" }

[tool.pdm.scripts]
isort = {shell = "isort src/melobot"}
format = {shell = "black src/melobot"}
check = {shell = "flake8 src/melobot"}
analyse = {shell = "mypy src/melobot"}
pylint = {shell = "pylint src/melobot"}
all_lint = {composite = ["isort", "format", "check", "analyse", "pylint"]}
isort = { shell = "isort --profile black src/melobot tests scripts docs" }
format = { shell = "black src/melobot tests scripts docs" }
check = { shell = "flake8 src/melobot" }
analyse = { shell = "mypy src/melobot" }
all_lint = { composite = ["isort", "format", "check", "analyse"] }

test = {shell = "pytest -c pytest.ini"}
trace = {shell = "viztracer"}
deps = {shell = "pydeps src/melobot -o pydeps.png -T png --only melobot --rankdir BT --max-module-depth 2 --start-color 160"}
docs = {call = "docs.make:main"}
test = { shell = "pytest -c pytest.ini" }
trace = { shell = "viztracer" }
deps = { shell = "pydeps src/melobot -o pydeps.png -T png --only melobot --rankdir BT --max-module-depth 2 --start-color 160" }
docs = { call = "docs.make:main" }

_deps_export = {call = "scripts.exports:main"}
_deps_export = { call = "scripts.exports:main" }
post_install.composite = ["_deps_export"]

[dependency-groups]
measure = [
"viztracer>=0.16.3",
"pydeps>=1.12.20",
"ipython",
]
measure = ["viztracer>=0.16.3", "pydeps>=1.12.20", "ipython"]
test = ["pytest>=8.1.1", "pytest-asyncio>=0.24.0"]
docs = ["sphinx>=7.3.7", "furo>=2024.1.29", "myst-parser>=2.0.0", "sphinx-copybutton>=0.5.2"]
lint = ["black>=24.2.0", "isort>=5.13.2", "flake8>=7.0.0", "pylint>=3.2.6", "mypy>=1.11.1"]
manage = [
"toml>=0.10.2",
"pre-commit>=4.0.1",
"ipython>=8.32.0",
docs = [
"sphinx>=7.3.7",
"furo>=2024.1.29",
"myst-parser>=2.0.0",
"sphinx-copybutton>=0.5.2",
]
lint = ["black>=24.2.0", "isort>=5.13.2", "flake8>=7.0.0", "mypy>=1.11.1"]
manage = ["toml>=0.10.2", "pre-commit>=4.0.1", "ipython>=8.32.0"]
4 changes: 1 addition & 3 deletions scripts/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
with open(r"pyproject.toml", "r", encoding="utf-8") as fp:
pyproj_toml = toml.load(fp)

except_groups = (
pyproj_toml["dependency-groups"] | pyproj_toml["project"]["optional-dependencies"]
)
except_groups = pyproj_toml["dependency-groups"] | pyproj_toml["project"]["optional-dependencies"]


def get_complement_groups(*groups: str | None) -> str:
Expand Down
8 changes: 2 additions & 6 deletions src/melobot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@

pinit_parser = sub_parsers.add_parser("pinit", help="运行 melobot 插件自动初始化")
pinit_parser.add_argument("files", nargs="*", help="插件根目录路径")
pinit_parser.add_argument(
"--depth", "-d", type=int, default=1, help="插件初始化的向上引用深度"
)
pinit_parser.add_argument("--depth", "-d", type=int, default=1, help="插件初始化的向上引用深度")
pinit_parser.set_defaults(_cmd_handler=pinit.main)

run_parser = sub_parsers.add_parser(
"run", help="以子进程模式运行 melobot bot 主程序,且支持重启"
)
run_parser = sub_parsers.add_parser("run", help="以子进程模式运行 melobot bot 主程序,且支持重启")
run_parser.add_argument("entry_file", help="bot 程序入口 .py 文件路径")
run_parser.set_defaults(_cmd_handler=run.main)

Expand Down
7 changes: 2 additions & 5 deletions src/melobot/_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@


class HookRunner(Generic[HookEnumT]):
def __init__(
self, type: HookEnumT, func: AsyncCallable[..., None], once: bool = False
) -> None:
def __init__(self, type: HookEnumT, func: AsyncCallable[..., None], once: bool = False) -> None:
self.type = type
self.callback: AsyncCallable[..., None] = inject_deps(func, manual_arg=True)
self.once = once
Expand Down Expand Up @@ -93,8 +91,7 @@ async def emit(
logger.debug(msg)

tasks = tuple(
asyncio.create_task(runner.run(*args, **kwargs))
for runner in self._hooks[hook_type]
asyncio.create_task(runner.run(*args, **kwargs)) for runner in self._hooks[hook_type]
)

if callback is not None:
Expand Down
Loading

0 comments on commit 3357356

Please sign in to comment.