typer
typer copied to clipboard
Async support optionally using anyio
I took a shot at supporting async as discussed in #88 while integrated feedback from the issue #88 and PR #332 . Unlike the existing proposal I decided to support both sync and async commands from the same decorator, as I don't see a reason to use two identical decorator functions.
anyio
is listed as an extra dependency. When anyio is not installed, asyncio is used, When anyio
and trio
are installed, the default engine becomes trio.
Other async engines, or customized behavior can be used by providing a custom run function via the async_runner
parameter to the decorator or Typer instance.
- [x] Support asyncio, anyio and trio
- [x] Anyio is only an optional dependency
- [x] Autocompletion works as expected
- [x] Updated documentation
- [x] Added unit tests
📝 Docs preview for commit 2aaa7983038c2dc065826854ee46f929da3e7757 at: https://62f6276299bc9823f965c724--typertiangolo.netlify.app
Codecov Report
Attention: Patch coverage is 90.72165%
with 18 lines
in your changes are missing coverage. Please review.
Project coverage is 99.72%. Comparing base (
1e43c6b
) to head (2aaa798
). Report is 126 commits behind head on master.
:exclamation: Current head 2aaa798 differs from pull request most recent head 1aba3c2. Consider uploading reports for the commit 1aba3c2 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #340 +/- ##
==========================================
+ Coverage 96.24% 99.72% +3.48%
==========================================
Files 280 289 +9
Lines 5942 6609 +667
==========================================
+ Hits 5719 6591 +872
+ Misses 223 18 -205
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@tiangolo will this reach main
? :sweat_smile:
📝 Docs preview for commit 54c908afcfe231f62ff52bb4ad206db6a30e5e58 at: https://1d41a6ff.typertiangolo.pages.dev
📝 Docs preview for commit aba2b6d19a9a05957eb5f57e7e61459e29a62a64 at: https://f2d58ec2.typertiangolo.pages.dev
📝 Docs preview for commit 60c15745eebf897de897dafd9d905f7b4442e69a at: https://0f102ae8.typertiangolo.pages.dev
📝 Docs preview for commit 150fe7a94e52afec21bb00810b2c4395b4b7531a at: https://66f933fb.typertiangolo.pages.dev
📝 Docs preview for commit 4be4aa4128ce9ef3b24cc1bd6e822757221be6e6 at: https://f6dd02b2.typertiangolo.pages.dev
📝 Docs preview for commit e3d923229c063992518f333cccd9791fce99d333 at: https://dc8389c6.typertiangolo.pages.dev
📝 Docs preview for commit c30baefc8e682385be1ce40f2c70bd4d53231150 at: https://e5083e4f.typertiangolo.pages.dev
📝 Docs preview for commit b45e696fdc2806c01873a65f0531eb11201e6dc3 at: https://5af393d9.typertiangolo.pages.dev
📝 Docs preview for commit 1aba3c258a7f81d5a76ebf3bc622a1a51f42d45e at: https://74e837fb.typertiangolo.pages.dev