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

Asynchronous CLI methods in CliApp #533

Merged
merged 6 commits into from
Feb 19, 2025

Merge branch 'main' into async-cli-command

f405e87
Select commit
Loading
Failed to load commit list.
Merged

Asynchronous CLI methods in CliApp #533

Merge branch 'main' into async-cli-command
f405e87
Select commit
Loading
Failed to load commit list.
Hyperlint AI / Hyperlint Style Guide succeeded Feb 19, 2025 in 11s

👏 No style guide issues found.

1 files reviewed, no outstanding issues found.

Details

📄 docs/index.md

LineIssuesTextComment
1118
  • (Spelling-error) Did you really mean 'Pydantic'?
  • (Spelling-error) Did you really mean 'async'?
  • (Spelling-error) Did you really mean 'Pydantic'?
  • (Spelling-error) Did you really mean 'subcommands'?
Existing:
Pydantic settings supports running asynchronous CLI commands via `CliApp.run` and `CliApp.run_subcommand`. With this feature, you can define async def methods within your Pydantic models (including subcommands) and have them executed just like their synchronous counterparts. Specifically:
All identified issues are false positives related to technical terms and common shorthand in programming. No corrections are necessary.
1120
  • (Spelling-error) Did you really mean 'cli_cmd'?
  • (Spelling-error) Did you really mean 'async'?
Existing:
1. Asynchronous methods are supported: You can now mark your cli_cmd or similar CLI entrypoint methods as async def and have CliApp execute them.
Both 'cli_cmd' and 'async' are code references or technical terms that are correctly used in this context. No changes are needed.
1121
  • (Spelling-error) Did you really mean 'Subcommands'?
  • (Spelling-error) Did you really mean 'subcommands'?
  • (Spelling-error) Did you really mean 'subcommand'?
Existing:
2. Subcommands may also be asynchronous: If you have nested CLI subcommands, the final (lowest-level) subcommand methods can likewise be asynchronous.
The term 'subcommand' is correctly used in the context of CLI documentation. The review process has flagged it incorrectly as a spelling error. No changes are necessary.
1122
  • (Spelling-error) Did you really mean 'subcommands'?
  • (Spelling-error) Did you really mean 'subcommands'?
  • (Spelling-error) Did you really mean 'async'?
Existing:
3. Limit asynchronous methods to final subcommands: Defining parent commands as asynchronous is not recommended, because it can result in additional threads and event loops being created. For best performance and to avoid unnecessary resource usage, only implement your deepest (child) subcommands as async def.
The terms 'subcommands' and 'async' are correctly used and spelled in this context. They are technical terms commonly used in programming, and the review process has mistakenly flagged them as spelling errors. No changes are needed.
1141(Spelling-error) Did you really mean 'Subcommands'?Existing:
#### Asynchronous Subcommands
The term 'Subcommands' is a valid technical term and is correctly used in this context. No change is needed as the style guide's alert is a false positive.
1143
  • (Spelling-error) Did you really mean 'subcommands'?
  • (Spelling-error) Did you really mean 'async'?
  • (Spelling-error) Did you really mean 'subcommand'?
Existing:
As mentioned above, you can also define subcommands as async. However, only do so for the leaf (lowest-level) subcommand to avoid spawning new threads and event loops unnecessarily in parent commands:
The terms 'subcommands', 'async', and 'subcommand' are correctly used in the context of software documentation. These are technical terms and not spelling errors. No changes are needed.
1180
  • (Spelling-error) Did you really mean 'subcommand'?
  • (Spelling-error) Did you really mean 'cli_cmd'?
  • (Spelling-error) Did you really mean 'Pydantic'?
  • (Spelling-error) Did you really mean 'async'?
  • (Spelling-error) Did you really mean 'subcommands'?
Existing:
When executing a subcommand with an asynchronous cli_cmd, Pydantic settings automatically detects whether the current thread already has an active event loop. If so, the async command is run in a fresh thread to avoid conflicts. Otherwise, it uses asyncio.run() in the current thread. This handling ensures your asynchronous subcommands “just work” without additional manual setup.
The terms flagged by the style guide are all valid in the context of this documentation. 'subcommand' and 'subcommands' are common terms in command-line interface documentation. 'cli_cmd' is a shorthand for command-line command. 'Pydantic' is a proper noun referring to a specific Python library. 'async' is a common shorthand for asynchronous in programming contexts. No changes are needed.

🪄 About Hyperlint

Hyperlint is your AI-powered copilot for creating high-quality documentation with minimal effort.

Sign up for a free plan at hyperlint.com.