TypeError: catch_warnings.__init__() got an unexpected keyword argument 'action'
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.10.2
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
1.execute command
poetry shell
flask db upgrade
2.error information
Traceback (most recent call last):
File "F:\Dify资料\ai408_dify\api\core\helper\module_import_helper.py", line 29, in import_module_from_source
spec.loader.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 "F:\Dify资料\ai408_dify\api\core\tools\provider\builtin\podcast_generator\tools\podcast_audio_generator.py", line 13, in <module>
with catch_warnings(action="ignore", category=RuntimeWarning):
**TypeError: catch_warnings.__init__() got an unexpected keyword argument 'action'**
ERROR:core.tools.tool_manager:load builtin provider identity=ToolProviderIdentity(author='Dify', name='podcast_generator', description=I18nObject(en_US='Generate podcast audio using Text-to-Speech services', zh_Hans='使用文字转语音服务生成播客 音频', pt_BR='Generate podcast audio using Text-to-Speech services', ja_JP='Generate podcast audio using Text-to-Speech services'), icon='icon.svg', label=I18nObject(en_US='Podcast Generator', zh_Hans='播客生成器', pt_BR='Podcast Generator', jadcast Generator'), tags=[]) tools=None credentials_schema={'tts_service': ToolProviderCredentials(name='tts_service', type=<CredentialsType.SELECT: 'select'>, required=True, default=None, options=[ToolCredentialsOption(value='openai', label=I18nObject(en_US='OpenAI TTS', zh_Hans='OpenAI TTS', pt_BR='OpenAI TTS', ja_JP='OpenAI TTS'))], label=I18nObject(en_US='TTS Service', zh_Hans='TTS 服务', pt_BR='TTS Service', ja_JP='TTS Service'), help=None, url=None, placeholder=I18nObject(en_US=elect a TTS service', zh_Hans='选择一个 TTS 服务', pt_BR='Select a TTS service', ja_JP='Select a TTS service')), 'api_key': ToolProviderCredentials(name='api_key', type=<CredentialsType.SECRET_INPUT: 'secret-input'>, required=True, default=Noneons=None, label=I18nObject(en_US='API Key', zh_Hans='API 密钥', pt_BR='API Key', ja_JP='API Key'), help=None, url=None, placeholder=I18nObject(en_US='Enter your TTS service API key', zh_Hans='输入您的 TTS 服务 API 密钥', pt_BR='Enter your TTS s key', ja_JP='Enter your TTS service API key'))} error: catch_warnings.__init__() got an unexpected keyword argument 'action'
✔️ Expected Behavior
execute the command 'flask db upgrade' normally
❌ Actual Behavior
TypeError: catch_warnings.init() got an unexpected keyword argument 'action'
Hey there, @ai408! 👋 I'm here to help you with bug fixes, answer questions, and even guide you on how to contribute. Let's squash those bugs together!
The error you're encountering is due to the incorrect use of the catch_warnings function. In Python, the catch_warnings context manager does not accept an action keyword argument. Instead, you should use the simplefilter function to ignore warnings. Here's how you can modify the code:
Replace this line:
with catch_warnings(action="ignore", category=RuntimeWarning):
With:
from warnings import catch_warnings, simplefilter
with catch_warnings():
simplefilter("ignore", category=RuntimeWarning)
This change should resolve the TypeError by correctly using the catch_warnings context manager and applying the simplefilter to ignore RuntimeWarning warnings.
To continue talking to Dosu, mention @dosu.
I suggest you pulling the latest code again. I can not reproduce this problem.
I suggest you pulling the latest code again. I can not reproduce this problem.
yes, sorry, I pull error branch.