typer icon indicating copy to clipboard operation
typer copied to clipboard

Async support optionally using anyio

Open skeletorXVI opened this issue 3 years ago • 12 comments

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

skeletorXVI avatar Nov 19 '21 02:11 skeletorXVI

📝 Docs preview for commit 2aaa7983038c2dc065826854ee46f929da3e7757 at: https://62f6276299bc9823f965c724--typertiangolo.netlify.app

github-actions[bot] avatar Aug 12 '22 10:08 github-actions[bot]

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

Files Patch % Lines
...ion/for_testing/commands_help_tutorial001_async.py 60.00% 8 Missing :warning:
typer/main.py 73.07% 7 Missing :warning:
...on/for_testing/commands_index_tutorial002_async.py 80.00% 2 Missing :warning:
docs_src/asynchronous/tutorial001.py 85.71% 1 Missing :warning:
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.

codecov[bot] avatar Aug 12 '22 10:08 codecov[bot]

@tiangolo will this reach main? :sweat_smile:

dekoza avatar Jul 02 '23 11:07 dekoza

📝 Docs preview for commit 54c908afcfe231f62ff52bb4ad206db6a30e5e58 at: https://1d41a6ff.typertiangolo.pages.dev

github-actions[bot] avatar Oct 12 '23 08:10 github-actions[bot]

📝 Docs preview for commit aba2b6d19a9a05957eb5f57e7e61459e29a62a64 at: https://f2d58ec2.typertiangolo.pages.dev

github-actions[bot] avatar Oct 17 '23 05:10 github-actions[bot]

📝 Docs preview for commit 60c15745eebf897de897dafd9d905f7b4442e69a at: https://0f102ae8.typertiangolo.pages.dev

github-actions[bot] avatar Oct 18 '23 06:10 github-actions[bot]

📝 Docs preview for commit 150fe7a94e52afec21bb00810b2c4395b4b7531a at: https://66f933fb.typertiangolo.pages.dev

github-actions[bot] avatar Oct 18 '23 08:10 github-actions[bot]

📝 Docs preview for commit 4be4aa4128ce9ef3b24cc1bd6e822757221be6e6 at: https://f6dd02b2.typertiangolo.pages.dev

github-actions[bot] avatar Oct 18 '23 09:10 github-actions[bot]

📝 Docs preview for commit e3d923229c063992518f333cccd9791fce99d333 at: https://dc8389c6.typertiangolo.pages.dev

github-actions[bot] avatar Oct 18 '23 13:10 github-actions[bot]

📝 Docs preview for commit c30baefc8e682385be1ce40f2c70bd4d53231150 at: https://e5083e4f.typertiangolo.pages.dev

github-actions[bot] avatar Oct 18 '23 13:10 github-actions[bot]

📝 Docs preview for commit b45e696fdc2806c01873a65f0531eb11201e6dc3 at: https://5af393d9.typertiangolo.pages.dev

github-actions[bot] avatar Oct 18 '23 14:10 github-actions[bot]

📝 Docs preview for commit 1aba3c258a7f81d5a76ebf3bc622a1a51f42d45e at: https://74e837fb.typertiangolo.pages.dev

github-actions[bot] avatar Oct 19 '23 05:10 github-actions[bot]