Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ jobs:
- "3.12"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
os:
- ubuntu-latest
- macos-latest
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ repos:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black
rev: 25.12.0
rev: 24.10.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py310-plus]
- repo: https://github.com/pycqa/flake8
rev: 7.3.0
rev: 7.1.2
hooks:
- id: flake8
additional_dependencies: [Flake8-pyproject]
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"isort.importStrategy": "fromEnvironment",
"black-formatter.importStrategy": "fromEnvironment",
"workbench.colorCustomizations": { /* do not change please... */}
}
}
20 changes: 10 additions & 10 deletions descope/authmethod/sso.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional, Dict
from typing import Any

from descope._auth_base import AuthBase
from descope.common import EndpointsV1, LoginOptions, validate_refresh_token_provided
Expand All @@ -9,13 +9,13 @@ class SSO(AuthBase):
def start(
self,
tenant: str,
return_url: Optional[str] = None,
login_options: Optional[LoginOptions] = None,
refresh_token: Optional[str] = None,
prompt: Optional[str] = None,
sso_id: Optional[str] = None,
login_hint: Optional[str] = None,
force_authn: Optional[bool] = None,
return_url: str | None = None,
login_options: LoginOptions | None = None,
refresh_token: str | None = None,
prompt: str | None = None,
sso_id: str | None = None,
login_hint: str | None = None,
force_authn: bool | None = None,
) -> dict:
"""
Start tenant sso session (saml/oidc based on tenant settings)
Expand Down Expand Up @@ -70,9 +70,9 @@ def _compose_start_params(
prompt: str,
sso_id: str,
login_hint: str,
force_authn: Optional[bool],
force_authn: bool | None,
) -> dict:
res: Dict[str, Any] = {"tenant": tenant}
res: dict[str, Any] = {"tenant": tenant}
if return_url is not None and return_url != "":
res["redirectURL"] = return_url
if prompt is not None and prompt != "":
Expand Down
106 changes: 53 additions & 53 deletions descope/management/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Dict, List, Optional, Any
from typing import Any, Optional


class SessionExpirationUnit(Enum):
Expand Down Expand Up @@ -30,7 +30,7 @@ def __init__(
self.sso_domains = sso_domains
self.group_mapping = group_mapping

def to_dict(self) -> Dict[str, bool]:
def to_dict(self) -> dict[str, bool]:
return {
"saml": self.saml,
"oidc": self.oidc,
Expand All @@ -44,15 +44,15 @@ class SSOSetupSuiteSettings:
def __init__(
self,
enabled: bool,
style_id: Optional[str] = None,
disabled_features: Optional[SSOSetupSuiteSettingsDisabledFeatures] = None,
style_id: str | None = None,
disabled_features: SSOSetupSuiteSettingsDisabledFeatures | None = None,
):
self.enabled = enabled
self.style_id = style_id
self.disabled_features = disabled_features

def to_dict(self) -> Dict[str, Any]:
result: Dict[str, Any] = {"enabled": self.enabled}
def to_dict(self) -> dict[str, Any]:
result: dict[str, Any] = {"enabled": self.enabled}
if self.style_id is not None:
result["styleId"] = self.style_id
if self.disabled_features is not None:
Expand Down Expand Up @@ -81,7 +81,7 @@ def to_dict(self) -> dict:
return {"name": self.name, "value": self.value}


def url_params_to_dict(url_params: Optional[List[URLParam]] = None) -> list:
def url_params_to_dict(url_params: list[URLParam] | None = None) -> list:
if url_params is None:
return []
return [param.to_dict() for param in url_params]
Expand Down Expand Up @@ -289,8 +289,8 @@ class MgmtV1:
class MgmtSignUpOptions:
def __init__(
self,
custom_claims: Optional[dict] = None,
refresh_duration: Optional[int] = None,
custom_claims: dict | None = None,
refresh_duration: int | None = None,
):
self.custom_claims = custom_claims
self.refresh_duration = refresh_duration
Expand All @@ -303,16 +303,16 @@ class FlowRunOptions:

def __init__(
self,
flow_input: Optional[Dict[str, Any]] = None,
preview: Optional[bool] = None,
tenant: Optional[str] = None,
flow_input: dict[str, Any] | None = None,
preview: bool | None = None,
tenant: str | None = None,
):
self.flow_input = flow_input
self.preview = preview
self.tenant = tenant

def to_dict(self) -> Dict[str, Any]:
result: Dict[str, Any] = {}
def to_dict(self) -> dict[str, Any]:
result: dict[str, Any] = {}
if self.flow_input is not None:
result["input"] = self.flow_input
if self.preview is not None:
Expand All @@ -322,7 +322,7 @@ def to_dict(self) -> Dict[str, Any]:
return result

@staticmethod
def from_dict(options: Optional[dict]) -> Optional["FlowRunOptions"]:
def from_dict(options: dict | None) -> Optional["FlowRunOptions"]:
if options is None:
return None
return FlowRunOptions(
Expand All @@ -337,10 +337,10 @@ def __init__(
self,
stepup: bool = False,
mfa: bool = False,
revoke_other_sessions: Optional[bool] = None,
custom_claims: Optional[dict] = None,
jwt: Optional[str] = None,
refresh_duration: Optional[int] = None,
revoke_other_sessions: bool | None = None,
custom_claims: dict | None = None,
jwt: str | None = None,
refresh_duration: int | None = None,
):
self.stepup = stepup
self.custom_claims = custom_claims
Expand All @@ -357,15 +357,15 @@ def is_jwt_required(lgo: MgmtLoginOptions) -> bool:
class MgmtUserRequest:
def __init__(
self,
name: Optional[str] = None,
given_name: Optional[str] = None,
middle_name: Optional[str] = None,
family_name: Optional[str] = None,
phone: Optional[str] = None,
email: Optional[str] = None,
email_verified: Optional[bool] = None,
phone_verified: Optional[bool] = None,
sso_app_id: Optional[str] = None,
name: str | None = None,
given_name: str | None = None,
middle_name: str | None = None,
family_name: str | None = None,
phone: str | None = None,
email: str | None = None,
email_verified: bool | None = None,
phone_verified: bool | None = None,
sso_app_id: str | None = None,
):
self.name = name
self.given_name = given_name
Expand Down Expand Up @@ -398,12 +398,12 @@ class AssociatedTenant:
roles for the user or access key in this specific tenant.
"""

def __init__(self, tenant_id: str, role_names: Optional[List[str]] = None):
def __init__(self, tenant_id: str, role_names: list[str] | None = None):
self.tenant_id = tenant_id
self.role_names = [] if role_names is None else role_names


def associated_tenants_to_dict(associated_tenants: List[AssociatedTenant]) -> list:
def associated_tenants_to_dict(associated_tenants: list[AssociatedTenant]) -> list:
associated_tenant_list = []
if associated_tenants:
for associated_tenant in associated_tenants:
Expand All @@ -429,7 +429,7 @@ def __init__(self, name: str, type: str, value: str):


def saml_idp_attribute_mapping_info_to_dict(
attributes_mapping: Optional[List[SAMLIDPAttributeMappingInfo]] = None,
attributes_mapping: list[SAMLIDPAttributeMappingInfo] | None = None,
) -> list:
attributes_mapping_list = []
if attributes_mapping:
Expand All @@ -455,7 +455,7 @@ def __init__(self, id: str, name: str):


def saml_idp_role_group_mapping_info_to_dict(
role_groups_mapping: Optional[List[SAMLIDPRoleGroupMappingInfo]] = None,
role_groups_mapping: list[SAMLIDPRoleGroupMappingInfo] | None = None,
) -> list:
role_groups_mapping_list = []
if role_groups_mapping:
Expand All @@ -481,7 +481,7 @@ def __init__(
type: str,
filter_type: str,
value: str,
roles: List[SAMLIDPRoleGroupMappingInfo],
roles: list[SAMLIDPRoleGroupMappingInfo],
):
self.name = name
self.type = type
Expand All @@ -491,7 +491,7 @@ def __init__(


def saml_idp_groups_mapping_info_to_dict(
groups_mapping: Optional[List[SAMLIDPGroupsMappingInfo]] = None,
groups_mapping: list[SAMLIDPGroupsMappingInfo] | None = None,
) -> list:
groups_mapping_list = []
if groups_mapping:
Expand All @@ -515,12 +515,12 @@ class Sort:
Represents a sort object.
"""

def __init__(self, field: str, desc: Optional[bool] = False):
def __init__(self, field: str, desc: bool | None = False):
self.field = field
self.desc = desc


def sort_to_dict(sort: List[Sort]) -> list:
def sort_to_dict(sort: list[Sort]) -> list:
sort_list = []
if sort:
for s in sort:
Expand Down Expand Up @@ -549,9 +549,9 @@ class DescoperAttributes:

def __init__(
self,
display_name: Optional[str] = None,
email: Optional[str] = None,
phone: Optional[str] = None,
display_name: str | None = None,
email: str | None = None,
phone: str | None = None,
):
self.display_name = display_name
self.email = email
Expand All @@ -572,8 +572,8 @@ class DescoperTagRole:

def __init__(
self,
tags: Optional[List[str]] = None,
role: Optional[DescoperRole] = None,
tags: list[str] | None = None,
role: DescoperRole | None = None,
):
self.tags = tags if tags is not None else []
self.role = role
Expand All @@ -592,8 +592,8 @@ class DescoperProjectRole:

def __init__(
self,
project_ids: Optional[List[str]] = None,
role: Optional[DescoperRole] = None,
project_ids: list[str] | None = None,
role: DescoperRole | None = None,
):
self.project_ids = project_ids if project_ids is not None else []
self.role = role
Expand All @@ -613,8 +613,8 @@ class DescoperRBAC:
def __init__(
self,
is_company_admin: bool = False,
tags: Optional[List[DescoperTagRole]] = None,
projects: Optional[List[DescoperProjectRole]] = None,
tags: list[DescoperTagRole] | None = None,
projects: list[DescoperProjectRole] | None = None,
):
self.is_company_admin = is_company_admin
self.tags = tags if tags is not None else []
Expand All @@ -636,9 +636,9 @@ class DescoperCreate:
def __init__(
self,
login_id: str,
attributes: Optional[DescoperAttributes] = None,
attributes: DescoperAttributes | None = None,
send_invite: bool = False,
rbac: Optional[DescoperRBAC] = None,
rbac: DescoperRBAC | None = None,
):
self.login_id = login_id
self.attributes = attributes
Expand All @@ -654,7 +654,7 @@ def to_dict(self) -> dict:
}


def descopers_to_dict(descopers: List[DescoperCreate]) -> list:
def descopers_to_dict(descopers: list[DescoperCreate]) -> list:
return [d.to_dict() for d in descopers]


Expand All @@ -664,7 +664,7 @@ class MgmtKeyStatus(Enum):


class MgmtKeyProjectRole:
def __init__(self, project_ids: List[str], roles: List[str]):
def __init__(self, project_ids: list[str], roles: list[str]):
self.project_ids = project_ids
self.roles = roles

Expand All @@ -676,7 +676,7 @@ def to_dict(self) -> dict:


class MgmtKeyTagRole:
def __init__(self, tags: List[str], roles: List[str]):
def __init__(self, tags: list[str], roles: list[str]):
self.tags = tags
self.roles = roles

Expand All @@ -690,9 +690,9 @@ def to_dict(self) -> dict:
class MgmtKeyReBac:
def __init__(
self,
company_roles: Optional[List[str]] = None,
project_roles: Optional[List[MgmtKeyProjectRole]] = None,
tag_roles: Optional[List[MgmtKeyTagRole]] = None,
company_roles: list[str] | None = None,
project_roles: list[MgmtKeyProjectRole] | None = None,
tag_roles: list[MgmtKeyTagRole] | None = None,
):
self.company_roles = company_roles
self.project_roles = project_roles
Expand Down
8 changes: 4 additions & 4 deletions descope/management/descoper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Any
from typing import Any

from descope._http_base import HTTPBase
from descope.management.common import (
Expand All @@ -13,7 +13,7 @@
class Descoper(HTTPBase):
def create(
self,
descopers: List[DescoperCreate],
descopers: list[DescoperCreate],
) -> dict:
"""
Create new Descopers.
Expand Down Expand Up @@ -44,8 +44,8 @@ def create(
def update(
self,
id: str,
attributes: Optional[DescoperAttributes] = None,
rbac: Optional[DescoperRBAC] = None,
attributes: DescoperAttributes | None = None,
rbac: DescoperRBAC | None = None,
) -> dict:
"""
Update an existing Descoper's RBAC and/or Attributes.
Expand Down
Loading
Loading