From c87e9dc6f5528af0849ffe1e0192895b65341a39 Mon Sep 17 00:00:00 2001 From: Daniel Fangl Date: Mon, 30 Sep 2024 19:44:58 +0200 Subject: [PATCH] Fix mypy error --- moto/iam/models.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/moto/iam/models.py b/moto/iam/models.py index 572e473106a9..340bdf6498bd 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -101,6 +101,12 @@ def mark_account_as_visited( pass +def _serialize_version_datetime(value: Any) -> str: + if isinstance(value, datetime): + return value.strftime("%Y-%m-%d") + raise TypeError("Unable to serialize value.") + + LIMIT_KEYS_PER_USER = 2 @@ -747,13 +753,8 @@ def create_from_cloudformation_json( # type: ignore[misc] assume_role_policy_document = properties["AssumeRolePolicyDocument"] if not isinstance(assume_role_policy_document, str): - - def _serialize_datetime(value): - if isinstance(value, datetime): - return value.strftime("%Y-%m-%d") - assume_role_policy_document = json.dumps( - assume_role_policy_document, default=_serialize_datetime + assume_role_policy_document, default=_serialize_version_datetime ) iam_backend = iam_backends[account_id][get_partition(region_name)]