You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the CliApp.run function only supports synchronous methods. When attempting to pass an asynchronous method to CliApp.run, an error is raised indicating that the coroutine was never awaited. As asynchronous programming becomes more prevalent in Python applications, it would be extremely helpful if CliApp could handle async methods out of the box.
Background
The pydantic-settings library provides a CliApp class that allows running methods of a BaseSettings subclass as CLI commands. However, passing an async method to CliApp.run triggers a warning because the method is never awaited internally.
Sample Code
frompydantic_settingsimportBaseSettings, CliAppclassAsyncSettings(BaseSettings):
asyncdefcli_cmd(self) ->None:
print('Hello from an async CLI method!')
Error
.../.venv/lib/python3.12/site-packages/pydantic_settings/main.py:450: RuntimeWarning: coroutine 'AsyncSettings.cli_cmd' was never awaited
getattr(type(model), cli_cmd_method_name)(model)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
The text was updated successfully, but these errors were encountered:
Currently, the CliApp.run function only supports synchronous methods. When attempting to pass an asynchronous method to CliApp.run, an error is raised indicating that the coroutine was never awaited. As asynchronous programming becomes more prevalent in Python applications, it would be extremely helpful if CliApp could handle async methods out of the box.
Background
The pydantic-settings library provides a CliApp class that allows running methods of a BaseSettings subclass as CLI commands. However, passing an async method to CliApp.run triggers a warning because the method is never awaited internally.
Sample Code
Error
The text was updated successfully, but these errors were encountered: