Skip to content

Commit

Permalink
Testing: Add type annotations to core/identity; #6588
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio authored and bari12 committed Apr 17, 2024
1 parent 92dbade commit 13ba29b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions lib/rucio/core/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@
from rucio.db.sqla.session import read_session, transactional_session

if TYPE_CHECKING:
from collections.abc import Sequence

from sqlalchemy import Row
from sqlalchemy.orm import Session


@transactional_session
def add_identity(identity: str, type_: IdentityType, email: str, password: Optional[str] = None, *, session: "Session"):
def add_identity(identity: str, type_: IdentityType, email: str, password: Optional[str] = None, *, session: "Session") -> None:
"""
Creates a user identity.
Expand Down Expand Up @@ -101,7 +104,7 @@ def verify_identity(identity: str, type_: IdentityType, password: Optional[str]


@transactional_session
def del_identity(identity: str, type_: IdentityType, *, session: "Session"):
def del_identity(identity: str, type_: IdentityType, *, session: "Session") -> None:
"""
Deletes a user identity.
Expand All @@ -123,7 +126,16 @@ def del_identity(identity: str, type_: IdentityType, *, session: "Session"):


@transactional_session
def add_account_identity(identity: str, type_: IdentityType, account: InternalAccount, email: str, default: bool = False, password: str = None, *, session: "Session"):
def add_account_identity(
identity: str,
type_: IdentityType,
account: InternalAccount,
email: str,
default: bool = False,
password: Optional[str] = None,
*,
session: "Session"
) -> None:
"""
Adds a membership association between identity and account.
Expand Down Expand Up @@ -165,7 +177,7 @@ def add_account_identity(identity: str, type_: IdentityType, account: InternalAc


@read_session
def exist_identity_account(identity: str, type_: IdentityType, account: InternalAccount, *, session: "Session"):
def exist_identity_account(identity: str, type_: IdentityType, account: InternalAccount, *, session: "Session") -> bool:
"""
Check if an identity is mapped to an account.
Expand All @@ -187,7 +199,7 @@ def exist_identity_account(identity: str, type_: IdentityType, account: Internal


@read_session
def get_default_account(identity: str, type_: IdentityType, oldest_if_none: bool = False, *, session: "Session"):
def get_default_account(identity: str, type_: IdentityType, oldest_if_none: bool = False, *, session: "Session") -> Optional[InternalAccount]:
"""
Retrieves the default account mapped to an identity.
Expand Down Expand Up @@ -228,7 +240,7 @@ def get_default_account(identity: str, type_: IdentityType, oldest_if_none: bool


@transactional_session
def del_account_identity(identity: str, type_: IdentityType, account: InternalAccount, *, session: "Session"):
def del_account_identity(identity: str, type_: IdentityType, account: InternalAccount, *, session: "Session") -> None:
"""
Removes a membership association between identity and account.
Expand All @@ -251,7 +263,7 @@ def del_account_identity(identity: str, type_: IdentityType, account: InternalAc


@read_session
def list_identities(*, session: "Session", **kwargs):
def list_identities(*, session: "Session", **kwargs) -> "Sequence[Row[tuple[str, IdentityType]]]":
"""
Returns a list of all identities.
Expand All @@ -269,7 +281,7 @@ def list_identities(*, session: "Session", **kwargs):


@read_session
def list_accounts_for_identity(identity: str, type_: IdentityType, *, session: "Session"):
def list_accounts_for_identity(identity: str, type_: IdentityType, *, session: "Session") -> "Sequence[InternalAccount]":
"""
Returns a list of all accounts for an identity.
Expand Down

0 comments on commit 13ba29b

Please sign in to comment.