forked from p15670423/monkey
Island: Add typehints to APIEncoder
This commit is contained in:
parent
ba9dda8d10
commit
18a7a4ec1a
|
@ -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):
|
||||||
|
|
Loading…
Reference in New Issue