diff --git a/nonebot/adapters/_template.py b/nonebot/adapters/_template.py index 82903dc5..8460436e 100644 --- a/nonebot/adapters/_template.py +++ b/nonebot/adapters/_template.py @@ -4,10 +4,8 @@ from string import Formatter from typing import ( TYPE_CHECKING, Any, - Callable, - Dict, - Optional, Set, + Dict, List, Type, Tuple, @@ -15,6 +13,8 @@ from typing import ( Generic, Mapping, TypeVar, + Callable, + Optional, Sequence, cast, overload, @@ -172,7 +172,7 @@ class MessageTemplate(Formatter, Generic[TF]): def format_field(self, value: Any, format_spec: str) -> Any: formatter: Optional[FormatSpecFunc] = self.format_specs.get(format_spec) - if (formatter is None) and (not issubclass(self.factory, str)): + if formatter is None and not issubclass(self.factory, str): segment_class: Type["MessageSegment"] = self.factory.get_segment_class() method = getattr(segment_class, format_spec, None) if inspect.ismethod(method): diff --git a/tests/test_init.py b/tests/test_init.py index 44411fb4..84477236 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -16,14 +16,11 @@ os.environ["CONFIG_FROM_ENV"] = '{"test": "test"}' @pytest.mark.parametrize( "nonebug_init", [ - { - "config_from_init": "init", - "driver": "nonebot.drivers.fastapi+nonebot.drivers.httpx+nonebot.drivers.websockets", - }, { "config_from_init": "init", "driver": "~fastapi+~httpx+~websockets", }, + {"config_from_init": "init", "driver": "~fastapi+~aiohttp"}, ], indirect=True, ) diff --git a/yarn.lock b/yarn.lock index 5ab23e40..844ee38e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1855,9 +1855,9 @@ integrity sha1-k+Jb+e51/g/YC1lLxP6w6GIRG1o= "@types/node@*": - version "17.0.5" - resolved "https://registry.npmmirror.com/@types/node/download/@types/node-17.0.5.tgz#57ca67ec4e57ad9e4ef5a6bab48a15387a1c83e0" - integrity sha512-w3mrvNXLeDYV1GKTZorGJQivK6XLCoGwpnyJFbJVK/aTBQUxOCaa/GlFAAN3OTDFcb7h5tiFG+YXCO2By+riZw== + version "17.0.6" + resolved "https://registry.npmmirror.com/@types/node/download/@types/node-17.0.6.tgz#cc1589c9ee853b389e67e8fb4384e0f250a139b9" + integrity sha512-+XBAjfZmmivILUzO0HwBJoYkAyyySSLg5KCGBDFLomJo0sV6szvVLAf4ANZZ0pfWzgEds5KmGLG9D5hfEqOhaA== "@types/parse-json@^4.0.0": version "4.0.0" @@ -2593,9 +2593,9 @@ camelcase-css@2.0.1, camelcase-css@^2.0.1: integrity sha1-7pePaUeRTMMMa0R0G27R338EP9U= camelcase@^6.2.0: - version "6.2.1" - resolved "https://registry.npmmirror.com/camelcase/download/camelcase-6.2.1.tgz?cache=0&sync_timestamp=1636945141024&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fcamelcase%2Fdownload%2Fcamelcase-6.2.1.tgz#250fd350cfd555d0d2160b1d51510eaf8326e86e" - integrity sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA== + version "6.3.0" + resolved "https://registry.npmmirror.com/camelcase/download/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-api@^3.0.0: version "3.0.0" @@ -2608,9 +2608,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001286, caniuse-lite@^1.0.30001294: - version "1.0.30001294" - resolved "https://registry.npmmirror.com/caniuse-lite/download/caniuse-lite-1.0.30001294.tgz#4849f27b101fd59ddee3751598c663801032533d" - integrity sha512-LiMlrs1nSKZ8qkNhpUf5KD0Al1KCBE3zaT7OLOwEkagXMEDij98SiOovn9wxVGQpklk9vVC/pUSqgYmkmKOS8g== + version "1.0.30001295" + resolved "https://registry.npmmirror.com/caniuse-lite/download/caniuse-lite-1.0.30001295.tgz#68a60f8f0664f342b2835c5d8898b4faea7b3d51" + integrity sha512-lSP16vcyC0FEy0R4ECc9duSPoKoZy+YkpGkue9G4D81OfPnliopaZrU10+qtPdT8PbGXad/PNx43TIQrOmJZSQ== ccount@^1.0.0, ccount@^1.0.3: version "1.1.0" @@ -2921,22 +2921,22 @@ copy-webpack-plugin@^9.0.1: serialize-javascript "^6.0.0" core-js-compat@^3.18.0, core-js-compat@^3.19.1: - version "3.20.1" - resolved "https://registry.npmmirror.com/core-js-compat/download/core-js-compat-3.20.1.tgz#96917b4db634fbbbc7b36575b2e8fcbf7e4f9691" - integrity sha512-AVhKZNpqMV3Jz8hU0YEXXE06qoxtQGsAqU0u1neUngz5IusDJRX/ZJ6t3i7mS7QxNyEONbCo14GprkBrxPlTZA== + version "3.20.2" + resolved "https://registry.npmmirror.com/core-js-compat/download/core-js-compat-3.20.2.tgz#d1ff6936c7330959b46b2e08b122a8b14e26140b" + integrity sha512-qZEzVQ+5Qh6cROaTPFLNS4lkvQ6mBzE3R6A6EEpssj7Zr2egMHgsy4XapdifqJDGC9CBiNv7s+ejI96rLNQFdg== dependencies: browserslist "^4.19.1" semver "7.0.0" core-js-pure@^3.19.0: - version "3.20.1" - resolved "https://registry.npmmirror.com/core-js-pure/download/core-js-pure-3.20.1.tgz#f7a2c62f98de83e4da8fca7b78846d3a2f542145" - integrity sha512-yeNNr3L9cEBwNy6vhhIJ0nko7fE7uFO6PgawcacGt2VWep4WqQx0RiqlkgSP7kqUMC1IKdfO9qPeWXcUheHLVQ== + version "3.20.2" + resolved "https://registry.npmmirror.com/core-js-pure/download/core-js-pure-3.20.2.tgz#5d263565f0e34ceeeccdc4422fae3e84ca6b8c0f" + integrity sha512-CmWHvSKn2vNL6p6StNp1EmMIfVY/pqn3JLAjfZQ8WZGPOlGoO92EkX9/Mk81i6GxvoPXjUqEQnpM3rJ5QxxIOg== core-js@^3.18.0: - version "3.20.1" - resolved "https://registry.npmmirror.com/core-js/download/core-js-3.20.1.tgz#eb1598047b7813572f1dc24b7c6a95528c99eef3" - integrity sha512-btdpStYFQScnNVQ5slVcr858KP0YWYjV16eGJQw8Gg7CWtu/2qNvIM3qVRIR3n1pK2R9NNOrTevbvAYxajwEjg== + version "3.20.2" + resolved "https://registry.npmmirror.com/core-js/download/core-js-3.20.2.tgz#46468d8601eafc8b266bd2dd6bf9dee622779581" + integrity sha512-nuqhq11DcOAbFBV4zCbKeGbKQsUDRqTX0oqx7AttUBuqe3h20ixsE039QHelbL6P4h+9kytVqyEtyZ6gsiwEYw== core-util-is@~1.0.0: version "1.0.3" @@ -2995,8 +2995,8 @@ css-declaration-sorter@^6.0.3: css-loader@^5.1.1: version "5.2.7" - resolved "https://registry.npmmirror.com/css-loader/download/css-loader-5.2.7.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fcss-loader%2Fdownload%2Fcss-loader-5.2.7.tgz#9b9f111edf6fb2be5dc62525644cbc9c232064ae" - integrity sha1-m58RHt9vsr5dxiUlZEy8nCMgZK4= + resolved "https://registry.npmmirror.com/css-loader/download/css-loader-5.2.7.tgz#9b9f111edf6fb2be5dc62525644cbc9c232064ae" + integrity sha512-Q7mOvpBNBG7YrVGMxRxcBJZFL75o+cH2abNASdibkj/fffYD8qWbInZrD0S9ccI6vZclF3DsHE7njGlLtaHbhg== dependencies: icss-utils "^5.1.0" loader-utils "^2.0.0" @@ -3344,19 +3344,19 @@ dns-txt@^2.0.2: buffer-indexof "^1.0.0" docusaurus-preset-nonepress@canary: - version "0.0.0-129" - resolved "https://registry.npmmirror.com/docusaurus-preset-nonepress/download/docusaurus-preset-nonepress-0.0.0-129.tgz#8aebd61840ae1a07a59c487559e3390a9902e2fa" - integrity sha512-sI5UdYlm9Xcaz70UyBJU9m8ERpw28UQyPYq/iCeohuQbFd8npdJXPgnklf4xN4+4N/oM+8M49auo7omnoJCNHg== + version "0.0.0-130" + resolved "https://registry.npmmirror.com/docusaurus-preset-nonepress/download/docusaurus-preset-nonepress-0.0.0-130.tgz#f2cebf94c4ea4bac4e63fb2e1439700b9a126a97" + integrity sha512-zJwEWkl1VCuXAP0YJcCCLkFpIXFl4YWoXAvm0smMsFPV9oYe6tV5Q1CXZAZNuUOFgMT4KAOYOis1fUNikV3c9Q== dependencies: "@docusaurus/core" "2.0.0-beta.9" "@docusaurus/plugin-content-docs" "2.0.0-beta.9" "@docusaurus/plugin-content-pages" "2.0.0-beta.9" - docusaurus-theme-nonepress "0.0.0-129" + docusaurus-theme-nonepress "0.0.0-130" -docusaurus-theme-nonepress@0.0.0-129: - version "0.0.0-129" - resolved "https://registry.npmmirror.com/docusaurus-theme-nonepress/download/docusaurus-theme-nonepress-0.0.0-129.tgz#58ae7151518318bb041a586b2f23d0b4043480b9" - integrity sha512-ETg0XuYpVQU8qIeTfPFj2V99oqbv5tyc4uLzYoO9t4YQ+PK7G8rMpVve6QxpMRCAiNyICWMqg9A6BkROf+z1bQ== +docusaurus-theme-nonepress@0.0.0-130: + version "0.0.0-130" + resolved "https://registry.npmmirror.com/docusaurus-theme-nonepress/download/docusaurus-theme-nonepress-0.0.0-130.tgz#26aaea857eb6c0c3061a632882e64a9b97269182" + integrity sha512-JlYLggAD/NB3FnoekiQuRHIdrznKSWcFKS/PJPGNtRNXgF603RLcsEwUlCuRwvHEMA6aqKGhvurlfDhqi/u6Ng== dependencies: "@docsearch/react" "^3.0.0-alpha.39" "@docusaurus/core" "2.0.0-beta.9" @@ -4420,13 +4420,6 @@ immer@^9.0.6: resolved "https://registry.npmmirror.com/immer/download/immer-9.0.7.tgz#b6156bd7db55db7abc73fd2fdadf4e579a701075" integrity sha512-KGllzpbamZDvOIxnmJ0jI840g7Oikx58lBPWV0hUh7dtAyZpFqqrBZdKka5GlTwMTZ1Tjc/bKKW4VSFAt6BqMA== -import-cwd@^3.0.0: - version "3.0.0" - resolved "https://registry.npm.taobao.org/import-cwd/download/import-cwd-3.0.0.tgz#20845547718015126ea9b3676b7592fb8bd4cf92" - integrity sha1-IIRVR3GAFRJuqbNna3WS+4vUz5I= - dependencies: - import-from "^3.0.0" - import-fresh@^3.1.0, import-fresh@^3.2.1, import-fresh@^3.2.2, import-fresh@^3.3.0: version "3.3.0" resolved "https://registry.npm.taobao.org/import-fresh/download/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" @@ -4435,13 +4428,6 @@ import-fresh@^3.1.0, import-fresh@^3.2.1, import-fresh@^3.2.2, import-fresh@^3.3 parent-module "^1.0.0" resolve-from "^4.0.0" -import-from@^3.0.0: - version "3.0.0" - resolved "https://registry.nlark.com/import-from/download/import-from-3.0.0.tgz#055cfec38cd5a27d8057ca51376d7d3bf0891966" - integrity sha1-BVz+w4zVon2AV8pRN219O/CJGWY= - dependencies: - resolve-from "^5.0.0" - import-lazy@^2.1.0: version "2.1.0" resolved "https://registry.nlark.com/import-lazy/download/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" @@ -4930,7 +4916,7 @@ leven@^3.1.0: resolved "https://registry.npmmirror.com/leven/download/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" integrity sha1-d4kd6DQGTMy6gq54QrtrFKE+1/I= -lilconfig@^2.0.3: +lilconfig@^2.0.3, lilconfig@^2.0.4: version "2.0.4" resolved "https://registry.npmmirror.com/lilconfig/download/lilconfig-2.0.4.tgz?cache=0&sync_timestamp=1636150747257&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Flilconfig%2Fdownload%2Flilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" integrity sha1-9FB9BD1wWLOAtqj1y3vNSzTO4II= @@ -5810,12 +5796,11 @@ postcss-js@^3.0.3: postcss "^8.1.6" postcss-load-config@^3.1.0: - version "3.1.0" - resolved "https://registry.npmmirror.com/postcss-load-config/download/postcss-load-config-3.1.0.tgz#d39c47091c4aec37f50272373a6a648ef5e97829" - integrity sha1-05xHCRxK7Df1AnI3OmpkjvXpeCk= + version "3.1.1" + resolved "https://registry.npmmirror.com/postcss-load-config/download/postcss-load-config-3.1.1.tgz#2f53a17f2f543d9e63864460af42efdac0d41f87" + integrity sha512-c/9XYboIbSEUZpiD1UQD0IKiUe8n9WHYV7YFe7X7J+ZwCsEKkUJSFWjS9hBU1RR9THR7jMXst8sxiqP0jjo2mg== dependencies: - import-cwd "^3.0.0" - lilconfig "^2.0.3" + lilconfig "^2.0.4" yaml "^1.10.2" postcss-loader@^6.1.1: @@ -6646,11 +6631,6 @@ resolve-from@^4.0.0: resolved "https://registry.npm.taobao.org/resolve-from/download/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha1-SrzYUq0y3Xuqv+m0DgCjbbXzkuY= -resolve-from@^5.0.0: - version "5.0.0" - resolved "https://registry.npm.taobao.org/resolve-from/download/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" - integrity sha1-w1IlhD3493bfIcV1V7wIfp39/Gk= - resolve-pathname@^3.0.0: version "3.0.0" resolved "https://registry.npm.taobao.org/resolve-pathname/download/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd"