fix: add type debbug

This commit is contained in:
dettlaff 2024-12-11 07:27:45 +04:00
parent be9be5c975
commit 41ca72ae24
2 changed files with 14 additions and 21 deletions

View file

@ -101,8 +101,6 @@ class UsersMutations:
UsernameTooLong, UsernameTooLong,
InvalidConfiguration, InvalidConfiguration,
KanidmDidNotReturnAdminPassword, KanidmDidNotReturnAdminPassword,
KanidmReturnUnknownResponseType,
KanidmReturnEmptyResponse,
KanidmQueryError, KanidmQueryError,
) as error: ) as error:
return return_failed_mutation_return( return return_failed_mutation_return(
@ -177,8 +175,6 @@ class UsersMutations:
PasswordIsEmpty, PasswordIsEmpty,
SelfPrivacyAppIsOutdate, SelfPrivacyAppIsOutdate,
KanidmDidNotReturnAdminPassword, KanidmDidNotReturnAdminPassword,
KanidmReturnUnknownResponseType,
KanidmReturnEmptyResponse,
KanidmQueryError, KanidmQueryError,
) as error: ) as error:
return return_failed_mutation_return( return return_failed_mutation_return(

View file

@ -102,20 +102,22 @@ class KanidmAdminToken: # TODO CHECK IS TOKEN CORRECT?
class KanidmUserRepository(AbstractUserRepository): class KanidmUserRepository(AbstractUserRepository):
"""
Validates the type and that content of the response data is not empty.
Args:
data_type (str): Expected type of response data ('list' or 'dict').
response_data (any): Response data to validate.
Raises:
KanidmReturnEmptyResponse: If the response data is empty.
KanidmReturnUnknownResponseType: If the response data is not of the expected type.
"""
@staticmethod @staticmethod
def _check_response_type_and_not_empty(data_type: str, response_data: Any) -> None: def _check_response_type_and_not_empty(data_type: str, response_data: Any) -> None:
"""
Validates the type and that content of the response data is not empty.
Args:
data_type (str): Expected type of response data ('list' or 'dict').
response_data (any): Response data to validate.
Raises:
KanidmReturnEmptyResponse: If the response data is empty.
KanidmReturnUnknownResponseType: If the response data is not of the expected type.
"""
logging.info(response_data)
if data_type == "list": if data_type == "list":
if not isinstance(response_data, list): if not isinstance(response_data, list):
raise KanidmReturnUnknownResponseType(response_data=response_data) raise KanidmReturnUnknownResponseType(response_data=response_data)
@ -128,9 +130,6 @@ class KanidmUserRepository(AbstractUserRepository):
if not response_data.get("data"): if not response_data.get("data"):
raise KanidmReturnEmptyResponse raise KanidmReturnEmptyResponse
else:
raise KanidmReturnUnknownResponseType(response_data=response_data)
@staticmethod @staticmethod
def _check_user_origin_by_memberof( def _check_user_origin_by_memberof(
memberof: list[str] = [], memberof: list[str] = [],
@ -173,8 +172,6 @@ class KanidmUserRepository(AbstractUserRepository):
raise KanidmQueryError(error_text=response.text) raise KanidmQueryError(error_text=response.text)
# nomatchingentries
@staticmethod @staticmethod
def create_user( def create_user(
username: str, username: str,