Island: Add typehints to APIEncoder

This commit is contained in:
vakarisz 2022-07-12 16:12:13 +03:00
parent ba9dda8d10
commit 18a7a4ec1a
1 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,7 @@
from datetime import datetime from datetime import datetime
from enum import Enum from enum import Enum
from json import loads from json import loads
from typing import Any
import bson import bson
from flask import make_response from flask import make_response
@ -10,7 +11,7 @@ from common.utils import IJSONSerializable
class APIEncoder(JSONEncoder): class APIEncoder(JSONEncoder):
def default(self, value): def default(self, value: Any):
# ObjectId is serializible by default, but returns a dict # ObjectId is serializible by default, but returns a dict
# So serialize it first into a plain string # So serialize it first into a plain string
if isinstance(value, bson.objectid.ObjectId): if isinstance(value, bson.objectid.ObjectId):