Skip to content

Conversation

LioriE
Copy link
Contributor

@LioriE LioriE commented Oct 5, 2025

Related Issues

https://github.com/descope/etc/issues/5922

Related PRs

branch PR
python-sdk: feat/async-tests (Link) PR #666

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

  • Tests
  • Documentation (if applicable)

LioriE added 3 commits October 5, 2025 10:47
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.
@LioriE LioriE changed the title [Feat] async methods [Feat] Async methods support Oct 5, 2025
@LioriE LioriE mentioned this pull request Oct 5, 2025
2 tasks
Copy link

github-actions bot commented Oct 5, 2025

Coverage report

The coverage rate went from 97.81% to 97.25% ⬇️

96% of new lines are covered.

Diff Coverage details (click to unfold)

descope/descope_client.py

100% of new lines are covered (97.79% of the complete file).

descope/management/tenant.py

100% of new lines are covered (100% of the complete file).

descope/management/flow.py

100% of new lines are covered (100% of the complete file).

descope/management/user.py

100% of new lines are covered (96.01% of the complete file).

descope/authmethod/saml.py

100% of new lines are covered (100% of the complete file).

descope/auth.py

75.36% of new lines are covered (91.35% of the complete file).
Missing lines: 139, 158, 159, 161, 164, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 179

descope/management/fga.py

100% of new lines are covered (100% of the complete file).

descope/management/group.py

100% of new lines are covered (100% of the complete file).

descope/management/access_key.py

100% of new lines are covered (100% of the complete file).

descope/authmethod/sso.py

100% of new lines are covered (100% of the complete file).

descope/management/sso_settings.py

100% of new lines are covered (100% of the complete file).

descope/management/authz.py

100% of new lines are covered (100% of the complete file).

descope/management/outbound_application.py

100% of new lines are covered (100% of the complete file).

descope/management/sso_application.py

100% of new lines are covered (100% of the complete file).

descope/authmethod/webauthn.py

100% of new lines are covered (100% of the complete file).

descope/management/permission.py

100% of new lines are covered (100% of the complete file).

descope/management/audit.py

100% of new lines are covered (75.55% of the complete file).

descope/authmethod/password.py

100% of new lines are covered (100% of the complete file).

descope/authmethod/oauth.py

100% of new lines are covered (100% of the complete file).

descope/future_utils.py

100% of new lines are covered (100% of the complete file).

descope/authmethod/enchantedlink.py

100% of new lines are covered (97.77% of the complete file).

descope/management/role.py

100% of new lines are covered (96.96% of the complete file).

descope/management/project.py

100% of new lines are covered (100% of the complete file).

descope/authmethod/totp.py

100% of new lines are covered (100% of the complete file).

descope/authmethod/magiclink.py

100% of new lines are covered (96.07% of the complete file).

descope/management/jwt.py

100% of new lines are covered (100% of the complete file).

descope/authmethod/otp.py

100% of new lines are covered (96.33% of the complete file).

@LioriE LioriE requested review from aviadl, dorsha, guyp-descope and omercnet and removed request for aviadl October 5, 2025 10:05
@omercnet omercnet requested a review from Copilot October 5, 2025 12:08
Copy link

@Copilot Copilot AI left a 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 to Auth and DescopeClient 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.

Comment on lines +359 to +371
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())
Copy link

Copilot AI Oct 5, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant