From ec122083b4f0adc696ac253f9b98942b4d8f6086 Mon Sep 17 00:00:00 2001 From: RF-Tar-Railt <3165388245@qq.com> Date: Mon, 19 Sep 2022 15:24:54 +0800 Subject: [PATCH] :bookmark: version 1.3.0 --- changelog.md | 14 +++-- pdm.lock | 81 ++++++++++++----------------- src/arclet/alconna/analysis/base.py | 8 +-- src/arclet/alconna/args.py | 2 +- src/arclet/alconna/core.py | 43 ++++++++------- 5 files changed, 70 insertions(+), 78 deletions(-) diff --git a/changelog.md b/changelog.md index c7705db9..b2e832d0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,16 @@ -# Alconna 1.2.x: +# Alconna 1.23.x: -## Alconna 1.2.1 +## Alconna 1.3.0 1. 修复 bugs -2. 完善命令补全功能 +2. 调整 Alconna的构造样式, 将header、command、options等合并; 兼容旧版写法到1.4 +3. 原先的builtins迁移至[`arclet-alconna-tools`](https://github.com/ArcletProject/Alconna-Tools), 只保留set_default、store_value与version +4. `set_default`可以附加一个 arg 名 +5. 调整repr样式 +6. 取消 shortcut的expiration +7. 新增命名空间配置,并将原先部分全局配置划为命名空间下的配置 +8. 允许.parse传入参数interrupt(bool)以在参数缺失的情况下可后续自行加参数 + +# Alconna 1.2.x: ## Alconna 1.2.0 ~ 1.2.0.7: 1. 修复 bugs diff --git a/pdm.lock b/pdm.lock index 9511c43d..d4218c10 100644 --- a/pdm.lock +++ b/pdm.lock @@ -24,11 +24,11 @@ dependencies = [ [[package]] name = "arclet-alconna" -version = "1.2.0" +version = "1.3.0" requires_python = ">=3.8" summary = "A High-performance, Generality, Humane Command Line Arguments Parser Library." dependencies = [ - "nepattern~=0.1.2", + "nepattern>=0.2.0", "typing-extensions~=4.3.0", ] @@ -43,18 +43,24 @@ dependencies = [ [[package]] name = "arclet-alconna-graia" -version = "0.4.7" +version = "0.4.1" requires_python = ">=3.8" summary = "Support Alconna to GraiaProject" dependencies = [ - "arclet-alconna<1.3.0,>=1.2.0", - "creart-graia~=0.1.5", - "creart~=0.2.1", - "graia-amnesia>=0.5.0", - "graia-ariadne<1.0.0,>=0.7.14", - "graia-broadcast>=0.18.0", - "graia-saya~=0.0.16", - "nepattern>=0.1.2", + "arclet-alconna", + "graia-amnesia", + "graia-ariadne", + "graia-broadcast", +] + +[[package]] +name = "arclet-alconna-tools" +version = "0.1.1" +requires_python = ">=3.8" +summary = "Builtin Tools for Alconna" +dependencies = [ + "arclet-alconna>=1.3.0", + "nepattern>=0.2.0", ] [[package]] @@ -63,12 +69,6 @@ version = "4.0.2" requires_python = ">=3.6" summary = "Timeout context manager for asyncio programs" -[[package]] -name = "atomicwrites" -version = "1.4.1" -requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -summary = "Atomic file writes." - [[package]] name = "attrs" version = "22.1.0" @@ -151,16 +151,6 @@ dependencies = [ "typing-extensions>=3.10.0; python_version < \"3.9\"", ] -[[package]] -name = "graia-saya" -version = "0.0.16" -requires_python = ">=3.7,<4.0" -summary = "" -dependencies = [ - "graia-broadcast>=0.12.1", - "loguru<0.7,>=0.5.3", -] - [[package]] name = "idna" version = "3.3" @@ -200,7 +190,7 @@ summary = "multidict implementation" [[package]] name = "nepattern" -version = "0.1.2" +version = "0.2.1" requires_python = ">=3.8" summary = "a complex pattern, support typing" dependencies = [ @@ -253,11 +243,10 @@ summary = "pyparsing module - Classes and methods to define and execute parsing [[package]] name = "pytest" -version = "7.1.2" +version = "7.1.3" requires_python = ">=3.7" summary = "pytest: simple powerful testing with Python" dependencies = [ - "atomicwrites>=1.0; sys_platform == \"win32\"", "attrs>=19.2.0", "colorama; sys_platform == \"win32\"", "iniconfig", @@ -308,7 +297,7 @@ dependencies = [ [metadata] lock_version = "4.0" -content_hash = "sha256:0ca199305e3d9d0179dbe5da5acec39df29380baba87e6414ca89b7f058b2bf4" +content_hash = "sha256:1ef3c39ecf0ea9a42e9ff34ae5386a5693b2cbbac63eecf9a1bc97763e5149d4" [metadata.files] "aiohttp 3.8.1" = [ @@ -389,20 +378,20 @@ content_hash = "sha256:0ca199305e3d9d0179dbe5da5acec39df29380baba87e6414ca89b7f0 {url = "https://files.pythonhosted.org/packages/27/6b/a89fbcfae70cf53f066ec22591938296889d3cc58fec1e1c393b10e8d71d/aiosignal-1.2.0.tar.gz", hash = "sha256:78ed67db6c7b7ced4f98e495e572106d5c432a93e1ddd1bf475e1dc05f5b7df2"}, {url = "https://files.pythonhosted.org/packages/3b/87/fe94898f2d44a93a35d5aa74671ed28094d80753a1113d68b799fab6dc22/aiosignal-1.2.0-py3-none-any.whl", hash = "sha256:26e62109036cd181df6e6ad646f91f0dcfd05fe16d0cb924138ff2ab75d64e3a"}, ] -"arclet-alconna 1.2.0" = [ - {url = "https://files.pythonhosted.org/packages/cb/58/9bf5b2efe1b61aeda26eb396ecc39261c3bd74c056ff7ccfbc9d6f9dc2a1/arclet-alconna-1.2.0.tar.gz", hash = "sha256:8057be072c49bc4388487d7e001c341e8a68a7fe2b72e65fa65eecbc36a77354"}, - {url = "https://files.pythonhosted.org/packages/cc/13/f8f7a5cb4d50b13238a746ffd866292457bb66b79bb91602e619b1feb052/arclet_alconna-1.2.0-py3-none-any.whl", hash = "sha256:e3913a893c5c469ef26af2b0bd93b70eabe70299d46dc05b782a20b2d2ec397d"}, -] "arclet-alconna-cli 0.1.0" = [ {url = "https://files.pythonhosted.org/packages/ec/1b/6559a1f61a845a71712e80ea9885a3d31c40398c0279d5cff3c0b9d19a9f/arclet_alconna_cli-0.1.0-py3-none-any.whl", hash = "sha256:1bcfa9f79ef3738e7b8316c6cd272785f74a39f4e2a3ce7dec444b7fba7f4b29"}, ] +"arclet-alconna-graia 0.4.1" = [ + {url = "https://files.pythonhosted.org/packages/b3/e7/c52a021050deb5c21607560e499d8882492709d39594c9a1434bb819631f/arclet_alconna_graia-0.4.1-py3-none-any.whl", hash = "sha256:f614cc809b4325e21f3c4d86d0c23545972a33cdf5b62cc38fd15326d766314a"}, +] +"arclet-alconna-tools 0.1.1" = [ + {url = "https://files.pythonhosted.org/packages/74/ed/72ef89bcac8cfb1de236f07ef2a32ba3edf9d93b11878df1d884dd75e185/arclet_alconna_tools-0.1.1-py3-none-any.whl", hash = "sha256:0ea174875d3ba9659bc6753909022897e610e7c165e21bbcc6ad1c4fc86f5ae9"}, + {url = "https://files.pythonhosted.org/packages/cc/de/c72315dd7317a84649cc1f548f0468e98d6dd7cf1c350abbaeea8fadae7d/arclet-alconna-tools-0.1.1.tar.gz", hash = "sha256:ecb898d25baa07c7038a340dcc33caf7774a7610814bea0e7a3e2483f3242667"}, +] "async-timeout 4.0.2" = [ {url = "https://files.pythonhosted.org/packages/54/6e/9678f7b2993537452710ffb1750c62d2c26df438aa621ad5fa9d1507a43a/async-timeout-4.0.2.tar.gz", hash = "sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15"}, {url = "https://files.pythonhosted.org/packages/d6/c1/8991e7c5385b897b8c020cdaad718c5b087a6626d1d11a23e1ea87e325a7/async_timeout-4.0.2-py3-none-any.whl", hash = "sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"}, ] -"atomicwrites 1.4.1" = [ - {url = "https://files.pythonhosted.org/packages/87/c6/53da25344e3e3a9c01095a89f16dbcda021c609ddb42dd6d7c0528236fb2/atomicwrites-1.4.1.tar.gz", hash = "sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11"}, -] "attrs 22.1.0" = [ {url = "https://files.pythonhosted.org/packages/1a/cb/c4ffeb41e7137b23755a45e1bfec9cbb76ecf51874c6f1d113984ecaa32c/attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, {url = "https://files.pythonhosted.org/packages/f2/bc/d817287d1aa01878af07c19505fafd1165cd6a119e9d0821ca1d1c20312d/attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"}, @@ -548,10 +537,6 @@ content_hash = "sha256:0ca199305e3d9d0179dbe5da5acec39df29380baba87e6414ca89b7f0 {url = "https://files.pythonhosted.org/packages/0b/14/e155d41933b6069a0ea85dd04aca5660cdf156aee4bd8b44117b9be751a1/graia_broadcast-0.18.2-py3-none-any.whl", hash = "sha256:dcb712dc5be29419c4b65dc649c4e7c795c834fb810682f6131b313d6bd3e740"}, {url = "https://files.pythonhosted.org/packages/84/5f/93cd697ef2cbdae2b9ed8ec0011713b40c872a495b0abcbdab186d02ade9/graia-broadcast-0.18.2.tar.gz", hash = "sha256:07b0285d417021c795c3c4f4f12713311fcdec10d63f8e7a8ed7964e2f1b7a5a"}, ] -"graia-saya 0.0.16" = [ - {url = "https://files.pythonhosted.org/packages/0d/e9/795f3a6dedc0498b5b92cdd207198a1fde6e7a26b8c1f579db881c70b5d7/graia-saya-0.0.16.tar.gz", hash = "sha256:4150d288a6a852b3d275715ded5e1de9031b4aa63ed98b5ba4232e1a0908ea11"}, - {url = "https://files.pythonhosted.org/packages/e9/5b/01846c42d0862ad97d21dfa57108e5bc0c67e580e8ba41ef6e48beda6252/graia_saya-0.0.16-py3-none-any.whl", hash = "sha256:21748a48a5d55d58d946cb8d4339360c2774caea21139f8952799e61819638e4"}, -] "idna 3.3" = [ {url = "https://files.pythonhosted.org/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {url = "https://files.pythonhosted.org/packages/62/08/e3fc7c8161090f742f504f40b1bccbfc544d4a4e09eb774bf40aafce5436/idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, @@ -629,9 +614,9 @@ content_hash = "sha256:0ca199305e3d9d0179dbe5da5acec39df29380baba87e6414ca89b7f0 {url = "https://files.pythonhosted.org/packages/f6/2c/2f48aa1fd3b89fb632de50c0567f8168e2b75d0b92326ca6ac991aecb0ee/multidict-6.0.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:05f6949d6169878a03e607a21e3b862eaf8e356590e8bdae4227eedadacf6e51"}, {url = "https://files.pythonhosted.org/packages/fa/a7/71c253cdb8a1528802bac7503bf82fe674367e4055b09c28846fdfa4ab90/multidict-6.0.2.tar.gz", hash = "sha256:5ff3bd75f38e4c43f1f470f2df7a4d430b821c4ce22be384e1459cb57d6bb013"}, ] -"nepattern 0.1.2" = [ - {url = "https://files.pythonhosted.org/packages/23/2e/a3b007a2214a9bb1de1680234bcfe63c29c89db12f88a5a966f746668e03/nepattern-0.1.2.tar.gz", hash = "sha256:a4a8dcc6e9be6f04a42b61e3c411a544cee85c3039279fc049d64748f656fc8e"}, - {url = "https://files.pythonhosted.org/packages/2e/a8/b08824944f8d15de8a25841a56ff4b4def7fd813aa487db3aabc1d851658/nepattern-0.1.2-py3-none-any.whl", hash = "sha256:2cea4933c1ad25dd06558084ae1f73ef0c909eeb1e5f7a2ec27a86018b50c59f"}, +"nepattern 0.2.1" = [ + {url = "https://files.pythonhosted.org/packages/5e/da/4b5f0a329c03120d989c47d596cd8afbae9b03d39475f5f295bccbe4021b/nepattern-0.2.1-py3-none-any.whl", hash = "sha256:7e600fee6895779444c6a8d003c9151043da60c9b7af6dc79326eb9e7d1ecc9e"}, + {url = "https://files.pythonhosted.org/packages/da/08/5a44ea2a3c45562455c80ce8969366e5ada051c43a7a51f8b78e69243c40/nepattern-0.2.1.tar.gz", hash = "sha256:5fff03f620bde6e49cf3e868f96ed0552d0302aa75c464f23b5aeb1648d52660"}, ] "packaging 21.3" = [ {url = "https://files.pythonhosted.org/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, @@ -690,9 +675,9 @@ content_hash = "sha256:0ca199305e3d9d0179dbe5da5acec39df29380baba87e6414ca89b7f0 {url = "https://files.pythonhosted.org/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, {url = "https://files.pythonhosted.org/packages/71/22/207523d16464c40a0310d2d4d8926daffa00ac1f5b1576170a32db749636/pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, ] -"pytest 7.1.2" = [ - {url = "https://files.pythonhosted.org/packages/4e/1f/34657c6ac56f3c58df650ba41f8ffb2620281ead8e11bcdc7db63cf72a78/pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"}, - {url = "https://files.pythonhosted.org/packages/fb/d0/bae533985f2338c5d02184b4a7083b819f6b3fc101da792e0d96e6e5299d/pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"}, +"pytest 7.1.3" = [ + {url = "https://files.pythonhosted.org/packages/a4/a7/8c63a4966935b0d0b039fd67ebf2e1ae00f1af02ceb912d838814d772a9a/pytest-7.1.3.tar.gz", hash = "sha256:4f365fec2dff9c1162f834d9f18af1ba13062db0c708bf7b946f8a5c76180c39"}, + {url = "https://files.pythonhosted.org/packages/e3/b9/3541bbcb412a9fd56593005ff32183825634ef795a1c01ceb6dee86e7259/pytest-7.1.3-py3-none-any.whl", hash = "sha256:1377bda3466d70b55e3f5cecfa55bb7cfcf219c7964629b967c37cf0bda818b7"}, ] "statv 0.3.2" = [ {url = "https://files.pythonhosted.org/packages/17/94/90af52fbb882f7d5a86f75b8f151fabb3540a01b592d5c12646b55712266/statv-0.3.2-py3-none-any.whl", hash = "sha256:32e430b21ab6a62695c67ab6cae3dba6e01e9c3fdbc9344e3236ad7a1f51d0c7"}, diff --git a/src/arclet/alconna/analysis/base.py b/src/arclet/alconna/analysis/base.py index 444fc42d..57f7c355 100644 --- a/src/arclet/alconna/analysis/base.py +++ b/src/arclet/alconna/analysis/base.py @@ -4,7 +4,7 @@ from .analyser import Analyser from .parts import analyse_args as ala, analyse_header as alh, analyse_option as alo, analyse_subcommand as als -from ..typing import DataCollection +from ..typing import DataCollection, TDataCollection from ..base import Option, Subcommand, Sentence from ..args import Args @@ -26,7 +26,7 @@ def default_params_parser(analyser: "Analyser"): require_len = 0 for opts in analyser.alconna.options: if isinstance(opts, Option): - _compile_opts(opts, analyser.command_params) + _compile_opts(opts, analyser.command_params) # type: ignore analyser.param_ids.update(opts.aliases) elif isinstance(opts, Subcommand): sub_require_len = 0 @@ -58,7 +58,7 @@ def compile(alconna: "Alconna", params_parser: Callable[[Analyser], None] = defa return _analyser -def analyse(alconna: "Alconna", command: DataCollection[Union[str, Any]]) -> "Arpamar": +def analyse(alconna: "Alconna", command: TDataCollection) -> "Arpamar[TDataCollection]": return compile(alconna).process(command).analyse().execute() @@ -82,7 +82,7 @@ def __new__(cls, *args, **kwargs): cls.message_cache = False return super().__new__(cls) - def analyse(self, message: Union[DataCollection[Union[str, Any]], None] = None): + def analyse(self, message=None, interrupt=False): pass diff --git a/src/arclet/alconna/args.py b/src/arclet/alconna/args.py index 3757f6fe..087da516 100644 --- a/src/arclet/alconna/args.py +++ b/src/arclet/alconna/args.py @@ -333,7 +333,7 @@ def __getitem__(self, item) -> Union["Args", Tuple[TAValue, ArgField]]: if isinstance(item, str) and self.argument.get(item): return self.argument[item]['value'], self.argument[item]['field'] if isinstance(item, slice) or isinstance(item, tuple) and list(filter(lambda x: isinstance(x, slice), item)): - raise InvalidParam(f"{self.__name__} 现在不支持切片; 应从 Args[a:b:c, x:y:z] 变为 Args[a,b,c][x,y,z]") + raise InvalidParam(f"{self.__class__.__name__} 现在不支持切片; 应从 Args[a:b:c, x:y:z] 变为 Args[a,b,c][x,y,z]") if not isinstance(item, tuple): self.__check_var__([str(item), item]) else: diff --git a/src/arclet/alconna/core.py b/src/arclet/alconna/core.py index 8b0d752f..886c8dc0 100644 --- a/src/arclet/alconna/core.py +++ b/src/arclet/alconna/core.py @@ -19,7 +19,6 @@ from .components.behavior import T_ABehavior from .components.duplication import Duplication - T_Duplication = TypeVar('T_Duplication', bound=Duplication) T_Header = Union[List[Union[str, object]], List[Tuple[object, str]]] @@ -143,7 +142,7 @@ class Alconna(CommandNode): headers: Union[List[Union[str, object]], List[Tuple[object, str]]] command: Union[str, Any] options: List[Union[Option, Subcommand]] - analyser_type: Type["TAnalyser"] + analyser_type: Type[Analyser] formatter_type: Type[TextFormatter] namespace: str meta: CommandMeta @@ -157,11 +156,11 @@ class Alconna(CommandNode): @classmethod def config( - cls, - *, - behaviors: Optional[List[T_ABehavior]] = None, - analyser_type: Optional[Type["TAnalyser"]] = None, - formatter_type: Optional[Type[TextFormatter]] = None, + cls, + *, + behaviors: Optional[List[T_ABehavior]] = None, + analyser_type: Optional[Type[TAnalyser]] = None, + formatter_type: Optional[Type[TextFormatter]] = None, ): """ 配置 Alconna 的默认属性 @@ -181,7 +180,7 @@ def __init__( meta: Optional[CommandMeta] = None, namespace: Optional[Union[str, Namespace]] = None, separators: Optional[Union[str, Iterable[str]]] = None, - analyser_type: Optional[Type["TAnalyser"]] = None, + analyser_type: Optional[Type[TAnalyser]] = None, behaviors: Optional[List[T_ABehavior]] = None, formatter_type: Optional[Type[TextFormatter]] = None, **kwargs @@ -205,7 +204,7 @@ def __init__( np_config = config.namespaces.setdefault(namespace.name, namespace) else: np_config = config.namespaces.setdefault(namespace, Namespace(namespace)) - self.headers = next(filter(lambda x: isinstance(x, list), args + (np_config.headers, ))) + self.headers = next(filter(lambda x: isinstance(x, list), args + (np_config.headers,))) # type: ignore try: self.command = next(filter(lambda x: not isinstance(x, (list, Option, Subcommand, Args)), args)) except StopIteration: @@ -214,7 +213,7 @@ def __init__( self.action_list = {"options": {}, "subcommands": {}, "main": None} self.namespace = np_config.name self.options.extend([HelpOption, ShortcutOption, CompletionOption]) - self.analyser_type = analyser_type or self.__class__.global_analyser_type + self.analyser_type = analyser_type or self.__class__.global_analyser_type # type: ignore self.behaviors = behaviors or self.__class__.global_behaviors.copy() self.behaviors.insert(0, ActionHandler()) self.formatter_type = formatter_type or self.__class__.global_formatter_type @@ -227,7 +226,7 @@ def __init__( action=action, separators=separators or np_config.separators.copy(), # type: ignore ) - self.name = f"{self.command or self.headers[0]}".replace(command_manager.sign, "") + self.name = f"{self.command or self.headers[0]}".replace(command_manager.sign, "") # type: ignore self._deprecate(kwargs) self._hash = self._calc_hash() command_manager.register(self) @@ -256,13 +255,13 @@ def _deprecate(self, kwargs): ) if key == "help_text": warnings.warn("'help_text' will not support in 1.4.0 !", DeprecationWarning, 2) - self.meta.description = value + self.meta.description = str(value) if key == "raise_exception": warnings.warn("'raise_exception' will not support in 1.4.0 !", DeprecationWarning, 2) - self.meta.raise_exception = value + self.meta.raise_exception = bool(value) if key == "is_fuzzy_match": warnings.warn("'is_fuzzy_match' will not support in 1.4.0 !", DeprecationWarning, 2) - self.meta.fuzzy_match = value + self.meta.fuzzy_match = bool(value) def __union__(self, other: Union["Alconna", AlconnaGroup]) -> AlconnaGroup: """ @@ -308,7 +307,7 @@ def set_custom_types(cls, **types: Type): cls.custom_types = types def shortcut( - self, short_key: str, command: Optional[TDataCollection] = None, delete: bool = False + self, short_key: str, command: Optional[TDataCollection] = None, delete: bool = False ): """添加快捷命令""" try: @@ -350,26 +349,26 @@ def add(self, name: str, *alias: str, args: Optional[Args] = None, sep: str = " @overload def parse( - self, message: TDataCollection, duplication: Type[T_Duplication], static: bool = True, interrupt: bool = False + self, message, duplication: Type[T_Duplication], static=True, interrupt=False ) -> T_Duplication: ... @overload def parse( - self, message: TDataCollection, duplication=None, static: bool = True, interrupt: bool = False + self, message: TDataCollection, duplication=None, static=True, interrupt=False ) -> Arpamar[TDataCollection]: ... @overload def parse( - self, message: TDataCollection, duplication=..., static: bool = True, interrupt: bool = True - ) -> TAnalyser: + self, message, duplication=None, static=True, interrupt=True + ) -> Analyser: ... def parse( - self, message: TDataCollection, duplication: Optional[Type[T_Duplication]] = None, - static: bool = True, interrupt: bool = False - ): + self, message: TDataCollection, duplication: Optional[Type[T_Duplication]] = None, + static: bool = True, interrupt: bool = False + ) -> Union[Analyser, Arpamar[TDataCollection], T_Duplication]: """命令分析功能, 传入字符串或消息链, 返回一个特定的数据集合类""" analyser = command_manager.require(self) if static else compile(self) analyser.process(message)