Skip to content

Commit d90e9c1

Browse files
author
Joel Collins
committed
Added extra type defs
1 parent 6ef3f4a commit d90e9c1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/labthings/labthing.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import logging
22
import uuid
33
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
56

67
from apispec import APISpec
78
from apispec_webframeworks.flask import FlaskPlugin
8-
from flask import url_for
9+
from flask import url_for, Flask
910

1011
from .actions.pool import Pool
1112
from .apispec import FlaskLabThingsPlugin, MarshmallowPlugin
@@ -65,7 +66,7 @@ class LabThing:
6566

6667
def __init__(
6768
self,
68-
app=None,
69+
app: Optional[Flask] = None,
6970
id_: str = None,
7071
prefix: str = "",
7172
title: str = "",
@@ -81,7 +82,7 @@ def __init__(
8182
else:
8283
self.id = id_
8384

84-
self.app = app # Becomes a Flask app
85+
self.app: Optional[Flask] = app # Becomes a Flask app
8586

8687
self.components: Dict[
8788
str, Any
@@ -122,7 +123,7 @@ def __init__(
122123
logging.getLogger().addHandler(self.log_handler)
123124

124125
# Representation formatter map
125-
self.representations = DEFAULT_REPRESENTATIONS
126+
self.representations: Dict[str, Callable] = DEFAULT_REPRESENTATIONS
126127

127128
# OpenAPI spec for Swagger docs
128129
self.spec: APISpec = APISpec(
@@ -133,10 +134,12 @@ def __init__(
133134
)
134135

135136
# Thing description
136-
self.thing_description = ThingDescription(external_links=external_links)
137+
self.thing_description: ThingDescription = ThingDescription(
138+
external_links=external_links
139+
)
137140

138141
# JSON encoder class
139-
self.json_encoder = json_encoder
142+
self.json_encoder: JSONEncoder = json_encoder
140143

141144
if app is not None:
142145
self.init_app(app)

0 commit comments

Comments
 (0)