From a65c04300a2495cca1cd0c8a5054bc5b7d09c442 Mon Sep 17 00:00:00 2001 From: fllesser Date: Sun, 1 Mar 2026 20:03:12 +0800 Subject: [PATCH 1/4] refactor: Mark `parse` and `parse_with_redirect` methods as final and allow empty file display names for `File` segments. --- pyproject.toml | 1 - src/nonebot_plugin_parser/helper.py | 3 +-- src/nonebot_plugin_parser/parsers/base.py | 4 +++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7b9da63d..54819ad1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,6 @@ dependencies = [ "nonebot-plugin-apscheduler>=0.5.0,<1.0.0", "nonebot-plugin-localstore>=0.7.4,<1.0.0", "nonebot-plugin-uninfo>=0.10.1,<1.0.0", - ] [project.urls] diff --git a/src/nonebot_plugin_parser/helper.py b/src/nonebot_plugin_parser/helper.py index 2dc0dd1d..3eb0cbc6 100644 --- a/src/nonebot_plugin_parser/helper.py +++ b/src/nonebot_plugin_parser/helper.py @@ -101,8 +101,7 @@ def file_seg( """文件 Seg""" if not display_name: display_name = file.name - if not display_name: - raise ValueError("文件名不能为空") + if pconfig.use_base64: return File(raw=file.read_bytes(), name=display_name) else: diff --git a/src/nonebot_plugin_parser/parsers/base.py b/src/nonebot_plugin_parser/parsers/base.py index ea11525b..114c900c 100644 --- a/src/nonebot_plugin_parser/parsers/base.py +++ b/src/nonebot_plugin_parser/parsers/base.py @@ -4,7 +4,7 @@ from asyncio import Task from pathlib import Path from collections.abc import Callable, Coroutine -from typing_extensions import Unpack +from typing_extensions import Unpack, final from .data import Platform, ParseResult, ParseResultKwargs from ..config import pconfig as pconfig @@ -83,9 +83,11 @@ def get_all_subclass(cls) -> list[type["BaseParser"]]: """获取所有已注册的 Parser 类""" return cls._registry + @final async def parse(self, keyword: str, searched: Match[str]) -> ParseResult: return await self._handlers[keyword](self, searched) + @final async def parse_with_redirect( self, url: str, From 826d1332eb1326572b1fcfdc948acf9206c2a8a5 Mon Sep 17 00:00:00 2001 From: fllesser Date: Sun, 1 Mar 2026 20:07:29 +0800 Subject: [PATCH 2/4] tweak --- uv.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uv.lock b/uv.lock index 2e381017..146036ca 100644 --- a/uv.lock +++ b/uv.lock @@ -113,14 +113,14 @@ wheels = [ [[package]] name = "asgiref" -version = "3.11.0" +version = "3.11.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions", marker = "python_full_version < '3.11' or (extra == 'group-21-nonebot-plugin-parser-pydantic-v1' and extra == 'group-21-nonebot-plugin-parser-pydantic-v2') or (extra == 'group-21-nonebot-plugin-parser-pydantic-v1' and extra == 'group-21-nonebot-plugin-parser-telegram') or (extra == 'group-21-nonebot-plugin-parser-pydantic-v2' and extra == 'group-21-nonebot-plugin-parser-telegram')" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/76/b9/4db2509eabd14b4a8c71d1b24c8d5734c52b8560a7b1e1a8b56c8d25568b/asgiref-3.11.0.tar.gz", hash = "sha256:13acff32519542a1736223fb79a715acdebe24286d98e8b164a73085f40da2c4", size = 37969, upload-time = "2025-11-19T15:32:20.106Z" } +sdist = { url = "https://files.pythonhosted.org/packages/63/40/f03da1264ae8f7cfdbf9146542e5e7e8100a4c66ab48e791df9a03d3f6c0/asgiref-3.11.1.tar.gz", hash = "sha256:5f184dc43b7e763efe848065441eac62229c9f7b0475f41f80e207a114eda4ce", size = 38550, upload-time = "2026-02-03T13:30:14.33Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/91/be/317c2c55b8bbec407257d45f5c8d1b6867abc76d12043f2d3d58c538a4ea/asgiref-3.11.0-py3-none-any.whl", hash = "sha256:1db9021efadb0d9512ce8ffaf72fcef601c7b73a8807a1bb2ef143dc6b14846d", size = 24096, upload-time = "2025-11-19T15:32:19.004Z" }, + { url = "https://files.pythonhosted.org/packages/5c/0a/a72d10ed65068e115044937873362e6e32fab1b7dce0046aeb224682c989/asgiref-3.11.1-py3-none-any.whl", hash = "sha256:e8667a091e69529631969fd45dc268fa79b99c92c5fcdda727757e52146ec133", size = 24345, upload-time = "2026-02-03T13:30:13.039Z" }, ] [[package]] @@ -1737,7 +1737,7 @@ fastapi = [ [[package]] name = "nonebug" version = "0.4.3" -source = { git = "https://github.com/nonebot/nonebug#864b208ae08433f28a01b3010e2da3ee3bfd2b61" } +source = { git = "https://github.com/nonebot/nonebug#53b893b7d412f941c2d0d769cc2e1c5526565296" } dependencies = [ { name = "asgiref" }, { name = "async-asgi-testclient" }, From 03d8dc3eba9cfb4b2edd0cdc94f6a25b8fc99ff0 Mon Sep 17 00:00:00 2001 From: fllesser Date: Sun, 1 Mar 2026 20:14:30 +0800 Subject: [PATCH 3/4] tweak --- pyproject.toml | 2 +- uv.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 54819ad1..ca9b0e81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,7 +113,7 @@ conflicts = [ ] [tool.uv.sources] -nonebug = { git = "https://github.com/nonebot/nonebug" } +nonebug = { git = "https://github.com/nonebot/nonebug", rev = "master" } [tool.bumpversion] tag = true diff --git a/uv.lock b/uv.lock index 146036ca..b5890218 100644 --- a/uv.lock +++ b/uv.lock @@ -1653,7 +1653,7 @@ dev = [ { name = "nonebot-plugin-htmlkit", specifier = ">=0.1.0rc4" }, { name = "nonebot-plugin-htmlrender", specifier = ">=0.6.7" }, { name = "nonebot2", extras = ["fastapi"], specifier = ">=2.4.3,<3.0.0" }, - { name = "nonebug", git = "https://github.com/nonebot/nonebug" }, + { name = "nonebug", git = "https://github.com/nonebot/nonebug?rev=master" }, { name = "poethepoet", specifier = ">=0.42.0" }, { name = "pytest-asyncio", specifier = ">=1.3.0,<1.4.0" }, { name = "pytest-cov", specifier = ">=7.0.0" }, @@ -1674,7 +1674,7 @@ pydantic-v1 = [{ name = "pydantic", specifier = "<2.0.0" }] pydantic-v2 = [{ name = "pydantic", specifier = ">=2.0.0" }] telegram = [{ name = "nonebot-adapter-telegram", specifier = ">=0.1.0b20" }] test = [ - { name = "nonebug", git = "https://github.com/nonebot/nonebug" }, + { name = "nonebug", git = "https://github.com/nonebot/nonebug?rev=master" }, { name = "poethepoet", specifier = ">=0.42.0" }, { name = "pytest-asyncio", specifier = ">=1.3.0,<1.4.0" }, { name = "pytest-cov", specifier = ">=7.0.0" }, @@ -1737,7 +1737,7 @@ fastapi = [ [[package]] name = "nonebug" version = "0.4.3" -source = { git = "https://github.com/nonebot/nonebug#53b893b7d412f941c2d0d769cc2e1c5526565296" } +source = { git = "https://github.com/nonebot/nonebug?rev=master#53b893b7d412f941c2d0d769cc2e1c5526565296" } dependencies = [ { name = "asgiref" }, { name = "async-asgi-testclient" }, From 30e05022bcac176c64059112044f68704f804500 Mon Sep 17 00:00:00 2001 From: fllesser Date: Sun, 1 Mar 2026 20:18:31 +0800 Subject: [PATCH 4/4] upgrade poe --- pyproject.toml | 2 +- uv.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ca9b0e81..eccb3b87 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ extras = [ ] test = [ "nonebug>=0.4.3,<1.0.0", - "poethepoet>=0.42.0", + "poethepoet>=0.42.1", "pytest-asyncio>=1.3.0,<1.4.0", "pytest-cov>=7.0.0", "pytest-xdist>=3.8.0,<4.0.0", diff --git a/uv.lock b/uv.lock index b5890218..335e9eca 100644 --- a/uv.lock +++ b/uv.lock @@ -1654,7 +1654,7 @@ dev = [ { name = "nonebot-plugin-htmlrender", specifier = ">=0.6.7" }, { name = "nonebot2", extras = ["fastapi"], specifier = ">=2.4.3,<3.0.0" }, { name = "nonebug", git = "https://github.com/nonebot/nonebug?rev=master" }, - { name = "poethepoet", specifier = ">=0.42.0" }, + { name = "poethepoet", specifier = ">=0.42.1" }, { name = "pytest-asyncio", specifier = ">=1.3.0,<1.4.0" }, { name = "pytest-cov", specifier = ">=7.0.0" }, { name = "pytest-xdist", specifier = ">=3.8.0,<4.0.0" }, @@ -1675,7 +1675,7 @@ pydantic-v2 = [{ name = "pydantic", specifier = ">=2.0.0" }] telegram = [{ name = "nonebot-adapter-telegram", specifier = ">=0.1.0b20" }] test = [ { name = "nonebug", git = "https://github.com/nonebot/nonebug?rev=master" }, - { name = "poethepoet", specifier = ">=0.42.0" }, + { name = "poethepoet", specifier = ">=0.42.1" }, { name = "pytest-asyncio", specifier = ">=1.3.0,<1.4.0" }, { name = "pytest-cov", specifier = ">=7.0.0" }, { name = "pytest-xdist", specifier = ">=3.8.0,<4.0.0" }, @@ -1900,16 +1900,16 @@ wheels = [ [[package]] name = "poethepoet" -version = "0.42.0" +version = "0.42.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pastel" }, { name = "pyyaml" }, { name = "tomli", marker = "python_full_version < '3.11' or (extra == 'group-21-nonebot-plugin-parser-pydantic-v1' and extra == 'group-21-nonebot-plugin-parser-pydantic-v2') or (extra == 'group-21-nonebot-plugin-parser-pydantic-v1' and extra == 'group-21-nonebot-plugin-parser-telegram') or (extra == 'group-21-nonebot-plugin-parser-pydantic-v2' and extra == 'group-21-nonebot-plugin-parser-telegram')" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/4a/9a/4e81fafef2ba94e5c974b4701343d1f053a27575ab5133cbd264348925dd/poethepoet-0.42.0.tar.gz", hash = "sha256:c9a2828259e585e9ed152857602130ff339f7b1638879b80d4a23f25588be4f8", size = 91278, upload-time = "2026-02-22T14:24:50.967Z" } +sdist = { url = "https://files.pythonhosted.org/packages/05/9b/e717572686bbf23e17483389c1bf3a381ca2427c84c7e0af0cdc0f23fccc/poethepoet-0.42.1.tar.gz", hash = "sha256:205747e276062c2aaba8afd8a98838f8a3a0237b7ab94715fab8d82718aac14f", size = 93209, upload-time = "2026-02-26T22:57:50.883Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/f1/3e/58041b7e4d49b69e859dc81c35e221cf02d91ed4dbb5a2f6cc4698a29f44/poethepoet-0.42.0-py3-none-any.whl", hash = "sha256:e43cc20d458ee5bfccaa4572bc5783bcb93991a7d2fcf8dadc9c43f1ebc9b277", size = 118091, upload-time = "2026-02-22T14:24:49.53Z" }, + { url = "https://files.pythonhosted.org/packages/c8/68/75fa0a5ef39718ea6ba7ab6a3d031fa93640e57585580cec85539540bb65/poethepoet-0.42.1-py3-none-any.whl", hash = "sha256:d8d1345a5ca521be9255e7c13bc2c4c8698ed5e5ac5e9e94890d239fcd423d0a", size = 119967, upload-time = "2026-02-26T22:57:49.467Z" }, ] [[package]]