Skip to content

Commit

Permalink
Fix mypy error
Browse files Browse the repository at this point in the history
  • Loading branch information
dfangl committed Oct 14, 2024
1 parent 69eb058 commit ba2b3a7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions moto/iam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit ba2b3a7

Please sign in to comment.