1
1
import logging
2
2
import uuid
3
3
import weakref
4
- from typing import Any , Dict , List , Optional , Set , Tuple , Type
4
+ from json import JSONEncoder
5
+ from typing import Any , Callable , Dict , List , Optional , Set , Tuple , Type
5
6
6
7
from apispec import APISpec
7
8
from apispec_webframeworks .flask import FlaskPlugin
8
- from flask import url_for
9
+ from flask import url_for , Flask
9
10
10
11
from .actions .pool import Pool
11
12
from .apispec import FlaskLabThingsPlugin , MarshmallowPlugin
@@ -65,7 +66,7 @@ class LabThing:
65
66
66
67
def __init__ (
67
68
self ,
68
- app = None ,
69
+ app : Optional [ Flask ] = None ,
69
70
id_ : str = None ,
70
71
prefix : str = "" ,
71
72
title : str = "" ,
@@ -81,7 +82,7 @@ def __init__(
81
82
else :
82
83
self .id = id_
83
84
84
- self .app = app # Becomes a Flask app
85
+ self .app : Optional [ Flask ] = app # Becomes a Flask app
85
86
86
87
self .components : Dict [
87
88
str , Any
@@ -122,7 +123,7 @@ def __init__(
122
123
logging .getLogger ().addHandler (self .log_handler )
123
124
124
125
# Representation formatter map
125
- self .representations = DEFAULT_REPRESENTATIONS
126
+ self .representations : Dict [ str , Callable ] = DEFAULT_REPRESENTATIONS
126
127
127
128
# OpenAPI spec for Swagger docs
128
129
self .spec : APISpec = APISpec (
@@ -133,10 +134,12 @@ def __init__(
133
134
)
134
135
135
136
# Thing description
136
- self .thing_description = ThingDescription (external_links = external_links )
137
+ self .thing_description : ThingDescription = ThingDescription (
138
+ external_links = external_links
139
+ )
137
140
138
141
# JSON encoder class
139
- self .json_encoder = json_encoder
142
+ self .json_encoder : JSONEncoder = json_encoder
140
143
141
144
if app is not None :
142
145
self .init_app (app )
0 commit comments