Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 默认使用 fake 适配器 #212

Merged
merged 1 commit into from
Apr 16, 2024
Merged

feat: 默认使用 fake 适配器 #212

merged 1 commit into from
Apr 16, 2024

Conversation

he0119
Copy link
Member

@he0119 he0119 commented Apr 16, 2024

防止测试中出现类似报错。

插件 nonebot_plugin_nai3 加载出错:
    04-16 03:42:49 [SUCCESS] nonebot | NoneBot is initializing...
    04-16 03:42:49 [INFO] nonebot | Current Env: prod
    04-16 03:42:49 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_smms"
    04-16 03:42:49 [ERROR] nonebot | Failed to import "nonebot_plugin_nai3"
    04-16 03:32:55 [SUCCESS] nonebot | NoneBot is initializing...
    04-16 03:32:55 [INFO] nonebot | Current Env: prod
    04-16 03:32:56 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_smms"
    04-16 03:32:56 [ERROR] nonebot | Failed to import "nonebot_plugin_nai3"
    Traceback (most recent call last):
      File "/home/runner/work/nonebot2/nonebot2/plugin_test/nonebot-plugin-nai3-nonebot_plugin_nai3-test/runner.py", line 15, in <module>
        plugin = load_plugin("nonebot_plugin_nai3")
      File "/home/runner/work/nonebot2/nonebot2/plugin_test/nonebot-plugin-nai3-nonebot_plugin_nai3-test/.venv/lib/python3.10/site-packages/nonebot/plugin/load.py", line 39, in load_plugin
        return manager.load_plugin(module_path)
    > File "/home/runner/work/nonebot2/nonebot2/plugin_test/nonebot-plugin-nai3-nonebot_plugin_nai3-test/.venv/lib/python3.10/site-packages/nonebot/plugin/manager.py", line 142, in load_plugin
        module = importlib.import_module(name)
      File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
      File "/home/runner/work/nonebot2/nonebot2/plugin_test/nonebot-plugin-nai3-nonebot_plugin_nai3-test/.venv/lib/python3.10/site-packages/nonebot/plugin/manager.py", line 242, in exec_module
        super().exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/home/runner/work/nonebot2/nonebot2/plugin_test/nonebot-plugin-nai3-nonebot_plugin_nai3-test/.venv/lib/python3.10/site-packages/nonebot_plugin_nai3/__init__.py", line 41, in <module>
        smms = SMMS()
      File "/home/runner/work/nonebot2/nonebot2/plugin_test/nonebot-plugin-nai3-nonebot_plugin_nai3-test/.venv/lib/python3.10/site-packages/nonebot_plugin_smms/smms.py", line 24, in __init__
        raise RuntimeError(
    RuntimeError: Current driver {'driver': '~none', 'host': IPv4Address('127.0.0.1'), 'port': 8080, 'log_level': 'INFO', 'api_timeout': 30.0, 'superusers': set(), 'nickname': set(), 'command_start': {'/'}, 'command_sep': {'.'}, 'session_expire_timeout': datetime.timedelta(seconds=120), 'nai3_token': 'xxx'} does not support http client requests! sm.ms plugin requires HTTPClient driver.

https://github.com/mobyw/nonebot-plugin-smms/blob/07fe3b48307cad05789d4090f87e7b89b4c2cac8/nonebot_plugin_smms/smms.py#L21-L32

    def __init__(self):
        driver = get_driver()
        if not isinstance(driver, HTTPClientMixin):
            raise RuntimeError(
                f"Current driver {driver.config.dict()} does not support "
                "http client requests! "
                "sm.ms plugin requires HTTPClient driver."
            )

@github-actions github-actions bot added the enhancement New feature or request label Apr 16, 2024
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.13%. Comparing base (daf3d1e) to head (9e30f06).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #212   +/-   ##
=======================================
  Coverage   98.13%   98.13%           
=======================================
  Files          17       17           
  Lines         966      966           
=======================================
  Hits          948      948           
  Misses         18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@he0119 he0119 merged commit b00fbdb into main Apr 16, 2024
7 checks passed
@he0119 he0119 deleted the feat/fake branch April 16, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant