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

Async support optionally using anyio #340

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

skeletorXVI
Copy link

@skeletorXVI skeletorXVI commented Nov 19, 2021

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.

  • Support asyncio, anyio and trio
  • Anyio is only an optional dependency
  • Autocompletion works as expected
  • Updated documentation
  • Added unit tests

@github-actions
Copy link

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

@codecov
Copy link

codecov bot commented Aug 12, 2022

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.

❗ 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 ⚠️
typer/main.py 73.07% 7 Missing ⚠️
...on/for_testing/commands_index_tutorial002_async.py 80.00% 2 Missing ⚠️
docs_src/asynchronous/tutorial001.py 85.71% 1 Missing ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dekoza
Copy link

dekoza commented Jul 2, 2023

@tiangolo will this reach main? 😅

# Conflicts:
#	pyproject.toml
#	tests/test_completion/test_completion.py
#	tests/test_completion/test_completion_install.py
#	tests/test_completion/test_completion_show.py
#	typer/main.py
@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions
Copy link

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

@skeletorXVI skeletorXVI marked this pull request as ready for review February 2, 2024 14:17
@svlandeg svlandeg added feature New feature, enhancement or request p3 labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request p3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants