-
Notifications
You must be signed in to change notification settings - Fork 8
[Feat] Async methods support #665
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
base: feat/httpx
Are you sure you want to change the base?
Conversation
Introduces async_mode and refactors authentication and client methods to support both synchronous and asynchronous usage. All relevant methods now return either direct results or awaitables, using futu_apply and futu_awaitable utilities. Updates all authentication method classes and DescopeClient to propagate async support, improving flexibility for async applications.
Coverage reportThe coverage rate went from
Diff Coverage details (click to unfold)descope/descope_client.py
descope/management/tenant.py
descope/management/flow.py
descope/management/user.py
descope/authmethod/saml.py
descope/auth.py
descope/management/fga.py
descope/management/group.py
descope/management/access_key.py
descope/authmethod/sso.py
descope/management/sso_settings.py
descope/management/authz.py
descope/management/outbound_application.py
descope/management/sso_application.py
descope/authmethod/webauthn.py
descope/management/permission.py
descope/management/audit.py
descope/authmethod/password.py
descope/authmethod/oauth.py
descope/future_utils.py
descope/authmethod/enchantedlink.py
descope/management/role.py
descope/management/project.py
descope/authmethod/totp.py
descope/authmethod/magiclink.py
descope/management/jwt.py
descope/authmethod/otp.py
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces async support for the Descope Python SDK by adding an async_mode
parameter and refactoring all authentication methods to return either direct results or awaitable objects. The implementation uses new future utility functions (futu_apply
, futu_awaitable
, futu_await
) to handle both synchronous and asynchronous execution modes seamlessly.
Key changes:
- Added
async_mode
parameter toAuth
andDescopeClient
constructors - Refactored HTTP request handling to support both sync and async patterns
- Updated all authentication and management methods to return Union types of direct results or Awaitable objects
- Added comprehensive test coverage for the new future utility functions
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
descope/future_utils.py |
New utility module providing async/sync bridging functions |
tests/test_future_utils.py |
Comprehensive test suite for future utility functions |
descope/auth.py |
Core Auth class refactored with async support and HTTP method abstraction |
descope/descope_client.py |
DescopeClient updated with async_mode parameter and return type annotations |
descope/authmethod/*.py |
All authentication methods updated to support async mode via futu_apply |
descope/management/*.py |
All management methods updated with Union return types and futu_apply integration |
tests/test_auth.py |
Test updates to reflect renamed private method |
pyproject.toml |
Test coverage threshold reduced from 98% to 97% |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
uri = MgmtV1.outbound_application_fetch_token_by_scopes_path | ||
response = self._auth.do_post( | ||
uri, | ||
{ | ||
"appId": app_id, | ||
"userId": user_id, | ||
"scopes": scopes, | ||
"options": options, | ||
"tenantId": tenant_id, | ||
}, | ||
pswd=self._auth.management_key, | ||
) | ||
return futu_apply(response, lambda response: response.json()) |
Copilot
AI
Oct 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fetch_token_by_scopes method now duplicates the logic from the static _OutboundApplicationTokenFetcher.fetch_token_by_scopes method instead of using it. This creates code duplication. The same issue exists for fetch_token, fetch_tenant_token_by_scopes, and fetch_tenant_token methods.
Copilot uses AI. Check for mistakes.
Related Issues
https://github.com/descope/etc/issues/5922
Related PRs
feat/async-tests
(Link)Description
Introduces async_mode and refactors authentication and client methods to support both synchronous and asynchronous usage. All relevant methods now return either direct results or awaitables, using futu_apply and futu_awaitable utilities. Updates all authentication method classes and DescopeClient to propagate async support, improving flexibility for async applications.
Tests remained as is for this PR to showcase the old functionality still upholds
Must